Skip to content

Commit 17afd4b

Browse files
Kalyan Krishnajmprieur
Kalyan Krishna
authored andcommitted
bug fixes and minor edits (#73)
* Minor edits * bug fixes and minor edits * fixed a bug * typos fixed
1 parent 159e716 commit 17afd4b

File tree

3 files changed

+48
-28
lines changed

3 files changed

+48
-28
lines changed

1-WebApp-OIDC/1-3-AnyOrgOrPersonal/AppCreationScripts/Configure.ps1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,10 @@ Function ConfigureApplications
127127

128128

129129
# Update config file for 'webApp'
130+
$commonendpoint = "common"
130131
$configFile = $pwd.Path + "\..\appsettings.json"
131132
Write-Host "Updating the sample code ($configFile)"
132-
$dictionary = @{ "ClientId" = $webAppAadApplication.AppId;"TenantId" = "common";"Domain" = $tenantName };
133+
$dictionary = @{ "ClientId" = $webAppAadApplication.AppId;"TenantId" = $commonendpoint;"Domain" = $tenantName };
133134
UpdateTextFile -configFilePath $configFile -dictionary $dictionary
134135

135136
Add-Content -Value "</tbody></table></body></html>" -Path createdApps.html

1-WebApp-OIDC/1-3-AnyOrgOrPersonal/AppCreationScripts/sample.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"Sample": {
3-
"Title": "An ASP.NET Core 2.x Web App which lets sign-in users with work and school or Microsoft personal accounts",
3+
"Title": "An ASP.NET Core 2.x Web App which sign-in users with either work and school or Microsoft personal accounts",
44
"Level": 200,
55
"Client": "ASP.NET Core 2.x Web App",
66
"Service": "Microsoft Graph",
@@ -19,7 +19,7 @@
1919
"Audience" : "AzureADandPersonalMicrosoftAccount",
2020
"HomePage": "https://localhost:44321/",
2121
"ReplyUrls": "https://localhost:44321/, https://localhost:44321/signin-oidc",
22-
"LogoutUrl": "https://localhost:44321/signout-oidc",
22+
"LogoutUrl": "https://localhost:44321/signout-oidc"
2323
}
2424
],
2525

@@ -41,7 +41,7 @@
4141
},
4242
{
4343
"key": "TenantId",
44-
"value": "common"
44+
"value": "$commonendpoint"
4545
},
4646
{
4747
"key": "Domain",

1-WebApp-OIDC/1-3-AnyOrgOrPersonal/README.md

Lines changed: 43 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,19 @@ level: 100
66
service: ASP.NET Core Web App
77
endpoint: AAD v2.0
88
---
9-
# Bulid an ASP.NET Core Web app signing-in users with the Microsoft identity platform
9+
# An ASP.NET Core 2.x Web App which sign-in users with either work and school or Microsoft personal accounts
1010

1111
> This sample is for Azure AD, not Azure AD B2C. See [active-directory-b2c-dotnetcore-webapp](https://github.com/Azure-Samples/active-directory-b2c-dotnetcore-webapp), until we incorporate the B2C variation in the tutorial.
1212
1313
![Build badge](https://identitydivision.visualstudio.com/_apis/public/build/definitions/a7934fdd-dcde-4492-a406-7fad6ac00e17/514/badge)
1414

1515
## Scenario
1616

17-
This sample shows how to build a .NET Core 2.2 MVC Web app that uses OpenID Connect to sign in users. Users can use personal accounts (including outlook.com, live.com, and others) as well as work and school accounts from any company or organization that has integrated with Azure Active Directory. It leverages the ASP.NET Core OpenID Connect middleware.
17+
This sample shows how to build an ASP.NET Core 2.2 MVC Web app that uses OpenID Connect to sign in users. Users can use either their personal accounts (including outlook.com, live.com, and others) as well as their work and school accounts. Thw work and school accounts are usually from an organization that has an Azure Active Directory tenant. It leverages the ASP.NET Core OpenID Connect middleware.
1818

1919
![Sign in with Azure AD](ReadmeFiles/sign-in.png)
2020

21-
> This is the first phase of a set of tutorials. Once you understand how to sign-in users in an ASP.NET Core Web App with Open Id Connect, can can learn how to enable your [Web App to call a Web API on behalf of the signed-in user](../../2-WebApp-graph-user)
21+
> This is the first chapter of a set of tutorials. Once you understand how to sign-in users in an ASP.NET Core Web App with Open Id Connect, can can learn how to enable your [Web App to call a Web API on behalf of the signed-in user](../../2-WebApp-graph-user)
2222
2323
## How to run this sample
2424

@@ -39,43 +39,62 @@ There is one project in this sample. To register it, you can:
3939
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope Process -Force
4040
```
4141

42-
3. Run the script to create your Azure AD application and configure the code of the sample application accordinly
42+
3. Run the following script to create and configure your Azure AD application and configure the code of the sample application as well.
4343

4444
```PowerShell
4545
.\AppCreationScripts\Configure.ps1
4646
```
4747

4848
> Other ways of running the scripts are described in [App Creation Scripts](./AppCreationScripts/AppCreationScripts.md)
4949
50-
4. Once you've run the script, be sure to follow the manual steps. Indeed Azure AD PowerShell does not create an app which audience is Work or School + personal accounts, even if this registration is already possible from the Azure portal:
51-
In the list of pages for the application registration of the application, select **Manifest**
52-
- search for **signInAudience** and make sure it's set to **AzureADandPersonalMicrosoftAccount**
53-
- Select **Save**
54-
55-
> Tip: If you register your apps with the scripts, to get directly to the app registration portal page for a give app, you can navigate to the links provided in the [AppCreationScripts\createdApps.html](AppCreationScripts\createdApps.html). This file is generated by the scripts during the app registration and configuration.
56-
57-
4. Open the Visual Studio solution and click start. That's it!
50+
4. Once you've run the script, please ensure that you've followed the following manual steps. Azure AD PowerShell does not yet create an app whose audience is `Work or School + personal accounts`. This audience setting is only possible from the Azure portal as of today:
51+
5. Sign in to the [Azure portal](https://portal.azure.com) using either a work or school account or a personal Microsoft account.
52+
6. If your account is present in more than one Azure AD tenant, select `Directory + Subscription` at the top right corner in the menu on top of the page, and switch your portal session to the desired Azure AD tenant.
53+
7. In the left-hand navigation blades, select the **Azure Active Directory** service, and then select **App registrations (Preview)**.
54+
8. In the **App registrations (Preview)** blade, locate your newly created app in the list.
55+
9. Select the **Manifest** blade for your app.
56+
10. Search for **signInAudience** and make sure it's set to **AzureADandPersonalMicrosoftAccount**
57+
58+
```JSON
59+
"signInUrl": null,
60+
"signInAudience": "AzureADandPersonalMicrosoftAccount",
61+
```
62+
63+
11. Click **Save** to save the app manifest.
64+
65+
> Tip: If you register your apps with the the provided Poweshell scripts, you can navigate directly to the app registration portal page of your newly created app, using links provided in the [AppCreationScripts\createdApps.html](AppCreationScripts\createdApps.html). This file is generated by the scripts during the app registration and configuration process.
66+
67+
12. Open the Visual Studio solution and click start. That's it!
5868

5969
- or, if you don't want to use automation, follow the steps below:
6070

6171
#### Choose the Azure AD tenant where you want to create your applications
6272

73+
As a first step you'll need to:
74+
6375
1. Sign in to the [Azure portal](https://portal.azure.com) using either a work or school account or a personal Microsoft account.
64-
1. If your account is present in more than one Azure AD tenant, select `Directory + Subscription` at the top right corner in the menu on top of the page, and switch your portal session to the desired Azure AD tenant.
65-
1. In the left-hand navigation pane, select the **Azure Active Directory** service, and then select **App registrations (Preview)**.
66-
1. In **App registrations (Preview)** page, select **New registration**.
76+
1. If your account is present in more than one Azure AD tenant, select your profile at the top right corner in the menu on top of the page, and then **switch directory**.
77+
Change your portal session to the desired Azure AD tenant.
78+
79+
#### Register the webApp app (WebApp)
80+
81+
1. Navigate to the Microsoft identity platform for developers [App registrations](https://go.microsoft.com/fwlink/?linkid=2083908) page.
82+
1. Select **New registration**.
6783
1. When the **Register an application page** appears, enter your application's registration information:
6884
- In the **Name** section, enter a meaningful application name that will be displayed to users of the app, for example `WebApp`.
6985
- In the **Supported account types** section, select **Accounts in any organizational directory and personal Microsoft accounts (e.g. Skype, Xbox, Outlook.com)**.
70-
- In the Redirect URI (optional) section, select **Web** in the combo-box.
71-
- For the *Redirect URI*, enter the base URL for the sample. By default, this sample uses `https://localhost:44321/`.
72-
- Select **Register** to create the application.
86+
> Note that there are more than one redirect URIs. You'll need to add them from the **Authentication** tab later after the app has been created succesfully.
87+
1. Select **Register** to create the application.
7388
1. On the app **Overview** page, find the **Application (client) ID** value and record it for later. You'll need it to configure the Visual Studio configuration file for this project.
74-
1. In the list of pages for the app, select **Authentication**.
75-
- In the **Redirect URIs**, add a redirect URL of type Web and valued `https://localhost:44321/signin-oidc`
89+
1. In the list of pages for the app, select **Authentication**..
90+
- In the Redirect URIs section, select **Web** in the combo-box and enter the following redirect URIs.
91+
- `https://localhost:44321/`
92+
- `https://localhost:44321/signin-oidc`
7693
- In the **Advanced settings** section set **Logout URL** to `https://localhost:44321/signout-oidc`
77-
- In the **Advanced settings** | **Implicit grant** section, check **ID tokens** as this sample requires the [Implicit grant flow](https://docs.microsoft.com/azure/active-directory/develop/v2-oauth2-implicit-grant-flow) to be enabled to sign-in the user.
78-
- Select **Save**.
94+
- In the **Advanced settings** | **Implicit grant** section, check **ID tokens** as this sample requires
95+
the [Implicit grant flow](https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-implicit-grant-flow) to be enabled to
96+
sign-in the user, and call an API.
97+
1. Select **Save**.
7998

8099
> Note that unless the Web App calls a Web API no certificate or secret is needed.
81100
@@ -111,7 +130,7 @@ In the **appsettings.json** file:
111130
> Note: Replace *`Enter_the_Application_Id_here`* with the *Application Id* from the application Id you just registered in the Application Registration Portal.
112131

113132
1. Open the generated project (.csproj) in Visual Studio, and save the solution.
114-
1. Add the `Microsoft.Identity.Web.csproj` project which is located at the root of this sample repo, to your solution (**Add Existing Project ...**). It's used to simplify signing-in and, in the next tutorial phases, to get a token
133+
1. Add the `Microsoft.Identity.Web.csproj` project which is located at the root of this sample repo, to your solution (**Add Existing Project ...**). It's used to simplify signing-in and, in the next tutorial phases, to get a token.
115134
1. Add a reference from your newly generated project to `Microsoft.Identity.Web` (right click on the **Dependencies** node under your new project, and choose **Add Reference ...**, and then in the projects tab find the `Microsoft.Identity.Web` project)
116135
1. Open the **Startup.cs** file and:
117136
@@ -188,7 +207,7 @@ You can also learn from the [1. WebApp signs-in users with Microsoft Identity (O
188207
189208
### known issue on iOS 12
190209
191-
ASP.NET core applications create session cookies that represent the identity of the caller. Some Safari users using iOS 12 had issues which are described in [ASP.NET Core #4467](https://github.com/aspnet/AspNetCore/issues/4647) and the Web kit bugs database [Bug 188165 - iOS 12 Safari breaks ASP.NET Core 2.1 OIDC authentication](https://bugs.webkit.org/show_bug.cgi?id=188165).
210+
ASP.NET core applications create session cookies that represent the identity of the caller. Some Safari users using iOS 12 had issues which are described in [ASP.NET Core #4467](https://github.com/aspnet/AspNetCore/issues/4647) and the Web kit bugs database [Bug 188165 - iOS 12 Safari breaks ASP.NET Core 2.1 OIDC authentication](https://bugs.webkit.org/show_bug.cgi?id=188165).
192211
193212
If your web site needs to be accessed from users using iOS 12, you probably want to disable the SameSite protection, but also ensure that state changes are protected with CSRF anti-forgery mecanism. See the how to fix section of [Microsoft Security Advisory: iOS12 breaks social, WSFed and OIDC logins #4647](https://github.com/aspnet/AspNetCore/issues/4647)
194213

0 commit comments

Comments
 (0)