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: README.md
+7-10Lines changed: 7 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,7 +18,7 @@ This sample shows how to build a .NET Core MVC Web app that uses OpenID Connect
18
18
19
19
To run this sample:
20
20
21
-
> Pre-requisites: - Install .NET Core (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).
21
+
> Pre-requisites: Install .NET Core (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).
22
22
23
23
### Step 1: Register the sample with your Azure AD tenant
24
24
@@ -29,7 +29,6 @@ To run this sample:
29
29
30
30
> Note: The base address in the **Sign-on URL** and **Logout URL** settings is `http://localhost:5000`. This localhost address allows the sample app to run insecurely from your local system. Port 5000 is the default port for the [Kestrel server](https://docs.microsoft.com/aspnet/core/fundamentals/servers/kestrel). Update these URLs if you configure the app for production use (for example, `https://www.contoso.com/signin-oidc` and `https://www.contoso.com/signout-oidc`).
31
31
32
-
33
32
### Step 2: Download/ Clone this sample code or build the application using a template
34
33
35
34
This sample was created from the dotnet core 2.0 [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:
@@ -53,9 +52,7 @@ You can clone this sample from your shell or command line:
53
52
54
53
> Note: Replace *`Enter_the_Application_Id_here`* with the *Application Id* from the application Id you just registered in the Application Registration Portal.
55
54
56
-
2. Open **Extensions\AzureAdAuthenticationBuilderExtensions.cs** file and Modify the `Configure` method to:
57
-
58
-
This method show be as follows (the changed lines are the lines containing `Authority`, and `ValidateIssuer`)
55
+
2. Open **Extensions\AzureAdAuthenticationBuilderExtensions.cs** file and replace the `Configure` method with:
59
56
60
57
```CSharp
61
58
public void Configure(string name, OpenIdConnectOptions options)
@@ -104,17 +101,17 @@ By default, when you use the dotnet core template with `SingleOrg` authenticatio
104
101
105
102
To restrict who can sign in to your application, use one of the options:
106
103
107
-
### Restrict access to a single organization (single-tenant)
104
+
### Option 1: Restrict access to a single organization (single-tenant)
108
105
109
-
You can restrict sign-in access for your application to only user accounts that are in a single Azure AD tenant - including *guest accounts* of that tenant. This scenario is a common for line-of-business applications:
106
+
You can restrict sign-in access for your application to only user accounts that are in a single Azure AD tenant - including *guest accounts* of that tenant. This scenario is a common for *line-of-business applications*:
110
107
111
108
1. Open **appsettings.json** and replace the line containing the `TenantId` value with the domain of your tenant, for example, *contoso.onmicrosoft.com* or the guid for the Tenant Id:
112
109
113
110
```json
114
111
"TenantId": "[Enter the domain of your tenant, e.g. contoso.onmicrosoft.com or the Tenant Id]",
115
112
```
116
113
117
-
2. In your **Extensions\AzureAdAuthenticationBuilderExtensions.cs** file, replace the `Configure` with:
114
+
2. In your **Extensions\AzureAdAuthenticationBuilderExtensions.cs** file, replace the `Configure` method with:
118
115
119
116
```CSharp
120
117
public void Configure(string name, OpenIdConnectOptions options)
@@ -127,14 +124,14 @@ You can restrict sign-in access for your application to only user accounts that
127
124
}
128
125
```
129
126
130
-
#### Restrict access to a list of organizations
127
+
### Option 2: Restrict access to a list of organizations
131
128
132
129
You can restrict sign-in access to only user accounts that are in a specific list of Azure AD organizations:
133
130
134
131
1. In your **Extensions\AzureAdAuthenticationBuilderExtensions.cs** file, set the `ValidateIssuer` argument to **`true`**
135
132
2. Add a `ValidIssuers` `TokenValidationParameters` parameter containing the list of allowed organizations.
136
133
137
-
#### Use a custom method to validate issuers
134
+
### Option 3: Use a custom method to validate issuers
138
135
139
136
You can implement a custom method to validate issuers by using the **IssuerValidator** parameter. For more information about how to use this parameter, read about the [TokenValidationParameters class](https://msdn.microsoft.com/library/system.identitymodel.tokens.tokenvalidationparameters.aspx) on MSDN.
0 commit comments