You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: .github/ISSUE_TEMPLATE.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,7 +16,7 @@ IF SUFFICIENT INFORMATION IS NOT PROVIDED VIA THE FOLLOWING TEMPLATE THE ISSUE M
16
16
17
17
Please add an 'x' for the scenario(s) where you found an issue
18
18
19
-
1.[ ]Web app that signs in users
19
+
1. Web app that signs in users
20
20
1.[ ] with a work and school account in your organization: [1-WebApp-OIDC/1-1-MyOrg](../blob/master/1-WebApp-OIDC/1-1-MyOrg)
21
21
1.[ ] with any work and school account: [/1-WebApp-OIDC/1-2-AnyOrg](../blob/master/1-WebApp-OIDC/1-2-AnyOrg)
22
22
1.[ ] with any work or school account or Microsoft personal account: [1-WebApp-OIDC/1-3-AnyOrgOrPersonal](../blob/master/1-WebApp-OIDC/1-3-AnyOrgOrPersonal)
@@ -27,7 +27,7 @@ Please add an 'x' for the scenario(s) where you found an issue
27
27
1.[ ] With specific token caches: [2-WebApp-graph-user/2-2-TokenCache](../blob/master/2-WebApp-graph-user/2-2-TokenCache)
28
28
1.[ ] Calling Microsoft Graph in national clouds: [2-WebApp-graph-user/2-4-Sovereign-Call-MSGraph](../blob/master/2-WebApp-graph-user/2-4-Sovereign-Call-MSGraph)
29
29
1.[ ] Web app calling several APIs [3-WebApp-multi-APIs](../blob/master/3-WebApp-multi-APIs)
30
-
1.[ ] Web app calling your own Web API
30
+
1.[ ] Web app calling your own Web API[4-WebApp-your-API](../blob/master/4-WebApp-your-API)
31
31
1. Web app restricting users
32
32
1.[ ] by Roles: [5-WebApp-AuthZ/5-1-Roles](../blob/master/5-WebApp-AuthZ/5-1-Roles)
33
33
1.[ ] by Groups: [5-WebApp-AuthZ/5-2-Groups](../blob/master/5-WebApp-AuthZ/5-2-Groups)
Copy file name to clipboardExpand all lines: 1-WebApp-OIDC/1-1-MyOrg/README.md
+49-23Lines changed: 49 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,18 +4,18 @@ platforms: dotnet
4
4
author: jmprieur
5
5
level: 100
6
6
client: ASP.NET Core Web App
7
-
endpoint: AAD v2.0
7
+
endpoint: Microsoft identity platform
8
8
---
9
9
10
10
# An ASP.NET Core Web app signing-in users with the Microsoft identity platform in your organization
11
11
12
-
> 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.
12
+
> This sample is for Azure AD, not Azure AD B2C. See [sample 1-5-B2C](https://github.com/Azure-Samples/active-directory-aspnetcore-webapp-openidconnect-v2/tree/master/1-WebApp-OIDC/1-5-B2C), for B2C scenario.
This sample shows how to build a .NET Core 2.2 MVC Web app that uses OpenID Connect to sign in users. Users can only sign-in with their `work and school` accounts in their own organization. It leverages the ASP.NET Core OpenID Connect middleware.
18
+
This sample shows how to build a .NET Core MVC Web app that uses OpenID Connect to sign in users. Users can only sign-in with their `work and school` accounts in their own organization. It leverages the ASP.NET Core OpenID Connect middleware.
19
19
20
20

21
21
@@ -26,32 +26,38 @@ This sample shows how to build a .NET Core 2.2 MVC Web app that uses OpenID Conn
26
26
27
27
To run this sample:
28
28
29
-
> Pre-requisites: Install .NET Core 2.2 or later (for example for Windows) by following the instructions at [.NET and C# - Get Started in 10 Minutes](https://www.microsoft.com/net/core). In addition to developing on Windows, you can develop on [Linux](https://www.microsoft.com/net/core#linuxredhat), [Mac](https://www.microsoft.com/net/core#macos), or [Docker](https://www.microsoft.com/net/core#dockercmd).
29
+
> Pre-requisites: Install .NET Core 3.0 or later (for example for Windows) by following the instructions at [.NET and C# - Get Started in 10 Minutes](https://www.microsoft.com/net/core). In addition to developing on Windows, you can develop on [Linux](https://www.microsoft.com/net/core#linuxredhat), [Mac](https://www.microsoft.com/net/core#macos), or [Docker](https://www.microsoft.com/net/core#dockercmd).
30
30
31
31
### Step 1: Register the sample with your Azure AD tenant
32
32
33
33
There is one project in this sample. To register it, you can:
34
34
35
-
- either use PowerShell scripts that **automatically** creates the Azure AD applications and related objects (passwords, permissions, dependencies) for you and modify the Visual Studio projects' configuration files. If you want to use this automation:
35
+
- either use PowerShell scripts that **automatically** creates the Azure AD applications and related objects (passwords, permissions, dependencies) for you and modify the Visual Studio projects' configuration files.
36
36
37
-
1. On Windows run PowerShell and navigate to the solution's folder
38
-
2. In PowerShell run:
37
+
<details>
38
+
<summary>Expand to see how to use this automation</summary>
39
39
40
-
```PowerShell
41
-
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope Process -Force
42
-
```
40
+
1. On Windows run PowerShell and navigate to the solution's folder
43
41
44
-
3. Run the script to create your Azure AD application and configure the code of the sample application accordinly
42
+
2. In PowerShell run:
45
43
46
-
```PowerShell
47
-
.\AppCreationScripts\Configure.ps1
48
-
```
44
+
```PowerShell
45
+
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope Process -Force
46
+
```
47
+
48
+
3. Run the script to create your Azure AD application and configure the code of the sample application accordingly
49
+
50
+
```PowerShell
51
+
.\AppCreationScripts\Configure.ps1
52
+
```
49
53
50
-
> Other ways of running the scripts are described in [App Creation Scripts](./AppCreationScripts/AppCreationScripts.md)
54
+
> Other ways of running the scripts are described in [App Creation Scripts](./AppCreationScripts/AppCreationScripts.md)
51
55
52
-
4. Open the Visual Studio solution and click start. That's it!
56
+
4. Open the Visual Studio solution and click start. That's it!
53
57
54
-
- or, if you don't want to use automation, follow the steps below:
58
+
</details>
59
+
60
+
- or, if you want to register your application with the Azure portal, follow the steps below:
55
61
56
62
#### Choose the Azure AD tenant where you want to create your applications
57
63
@@ -68,9 +74,23 @@ As a first step you'll need to:
68
74
1. When the **Register an application page** appears, enter your application's registration information:
69
75
- In the **Name** section, enter a meaningful application name that will be displayed to users of the app, for example `WebApp`.
70
76
- In the **Supported account types** section, select **Accounts in this organizational directory only ({tenant name})**.
> 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.
84
+
72
85
1. Select **Register** to create the application.
73
86
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.
> Note that unless the Web App calls a Web API, no certificate or secret is needed.
85
112
86
113
### Step 2: Download/ Clone this sample code or build the application using a template
87
114
88
-
This sample was created from the dotnet core 2.2 [dotnet new mvc](https://docs.microsoft.com/dotnet/core/tools/dotnet-new?tabs=netcore2x) template with `SingleOrg` authentication, and then tweaked to let it support tokens for the Azure AD V2 endpoint. You can clone/download this repository or create the sample from the command line:
115
+
This sample was created from the dotnet core 2.2 [dotnet new mvc](https://docs.microsoft.com/dotnet/core/tools/dotnet-new?tabs=netcore2x) template with `SingleOrg` authentication, and then tweaked to let it support tokens for the Microsoft identity platform endpoint. You can clone/download this repository or create the sample from the command line:
89
116
90
117
#### Option 1: Download/ clone this sample
91
118
@@ -136,10 +163,10 @@ cd "1-WebApp-OIDC\1-1-MyOrg"
This enables your application to use the Microsoft identity platform (formerly Azure AD v2.0) endpoint. This endpoint is capable of signing-in users both with their Work and School and Microsoft Personal accounts.
169
+
This enables your application to use the Microsoft identity platform endpoint. This endpoint is capable of signing-in users both with their Work and School and Microsoft Personal accounts.
143
170
144
171
1. Change the `Properties\launchSettings.json` file to ensure that you start your web app from <https://localhost:44321> as registered. For this:
145
172
- update the `sslPort` of the `iisSettings` section to be `44321`
@@ -149,16 +176,15 @@ cd "1-WebApp-OIDC\1-1-MyOrg"
149
176
150
177
1. Build the solution and run it.
151
178
152
-
2. Open your web browser and make a request to the app. Accept the IIS Express SSL certificate if needed. The app immediately attempts to authenticate you via the Azure AD v2 endpoint. Sign in with your personal account or with work or school account.
153
-
179
+
2. Open your web browser and make a request to the app. Accept the IIS Express SSL certificate if needed. The app immediately attempts to authenticate you via the identity platform endpoint. Sign in with your personal account or with work or school account.
154
180
155
181
## Toubleshooting
156
182
157
183
### known issue on iOS 12
158
184
159
185
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).
160
186
161
-
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)
187
+
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 mechanism. 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)
162
188
163
189
> Did the sample not work for you as expected? Did you encounter issues trying this sample? Then please reach out to us using the [GitHub Issues](../../../../issues) page.
Copy file name to clipboardExpand all lines: 1-WebApp-OIDC/1-1-MyOrg/Views/Home/Index.cshtml
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@
6
6
ASP.NET Core web app signing-in users in your organization
7
7
</h1>
8
8
<p>
9
-
This sample shows how to build a .NET Core 2.2 MVC Web app that uses OpenID Connect to sign in users in your organization. It leverages the ASP.NET Core OpenID Connect middleware.
9
+
This sample shows how to build a .NET Core MVC Web app that uses OpenID Connect to sign in users in your organization. It leverages the ASP.NET Core OpenID Connect middleware.
Copy file name to clipboardExpand all lines: 1-WebApp-OIDC/1-1-MyOrg/Views/Shared/Error.cshtml
+4-1Lines changed: 4 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -18,5 +18,8 @@
18
18
Swapping to <strong>Development</strong> environment will display more detailed information about the error that occurred.
19
19
</p>
20
20
<p>
21
-
<strong>Development environment should not be enabled in deployed applications</strong>, as it can result in sensitive information from exceptions being displayed to end users. For local debugging, development environment can be enabled by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>, and restarting the application.
21
+
<strong>The Development environment shouldn't be enabled for deployed applications.</strong>
22
+
It can result in displaying sensitive information from exceptions to end users.
23
+
For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>
0 commit comments