Skip to content

Commit d35646e

Browse files
committed
more API updates w/latest build
1 parent cd0528f commit d35646e

File tree

22 files changed

+62
-126
lines changed

22 files changed

+62
-126
lines changed

1-WebApp-OIDC/1-2-AnyOrg/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,14 +221,14 @@ These steps are encapsulated in the [Microsoft.Identity.Web](..\..\Microsoft.Ide
221221
222222
In order to restrict users from specific organizations from signing-in to your web app, you'll need to customize your code a bit more to restrict issuers. In Azure AD, the token issuers are the Azure AD tenants which issue tokens to applications.
223223

224-
In the `Startup.cs` file, in the `ConfigureServices` method, after `services.AddMicrosoftIdentityPlatformAuthentication(Configuration)` add some code to filter issuers by overriding the `TokenValidationParameters.IssuerValidator` delegate.
224+
In the `Startup.cs` file, in the `ConfigureServices` method, after `services.AddMicrosoftWebAppAuthentication(Configuration)` add some code to filter issuers by overriding the `TokenValidationParameters.IssuerValidator` delegate.
225225

226226
```CSharp
227227
public void ConfigureServices(IServiceCollection services)
228228
{
229229
...
230230
// Sign-in users with the Microsoft identity platform
231-
services.AddMicrosoftWebApp(Configuration);
231+
services.AddMicrosoftWebAppAuthentication(Configuration);
232232
233233
// Restrict users to specific belonging to specific tenants
234234
services.Configure<OpenIdConnectOptions>(OpenIdConnectDefaults.AuthenticationScheme, options =>

1-WebApp-OIDC/1-5-B2C/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ Here is the middleware example:
130130

131131
Important things to notice:
132132

133-
- The method `AddMicrosoftWebAppAuthenticatio` will configure the authentication based on the `MicrosoftIdentityOptions.cs` options. Feel free to bind more properties on `AzureAdB2C` section on `appsettings.json` if you need to set more options.
133+
- The method `AddMicrosoftWebAppAuthentication` will configure the authentication based on the `MicrosoftIdentityOptions.cs` options. Feel free to bind more properties on `AzureAdB2C` section on `appsettings.json` if you need to set more options.
134134
- The urls you set for `CallbackPath` and `SignedOutCallbackPath` should be registered on the **Reply Urls** of your application, in [Azure Portal](https://portal.azure.com).
135135

136136
## Next steps

2-WebApp-graph-user/2-1-Call-MSGraph/README.md

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -100,13 +100,9 @@ After the following lines in the ConfigureServices(IServiceCollection services)
100100
public void ConfigureServices(IServiceCollection services)
101101
{
102102
. . .
103-
services.AddAuthentication(OpenIdConnectDefaults.AuthenticationScheme)
104-
.AddMicrosoftWebApp(Configuration)
105-
106-
// Token acquisition service based on MSAL.NET
107-
// and chosen token cache implementation
108-
.AddMicrosoftWebAppCallsWebApi(Configuration, new string[] { Constants.ScopeUserRead });
109-
services.AddInMemoryTokenCaches();
103+
services.AddMicrosoftWebAppAuthentication(Configuration)
104+
.AddMicrosoftWebAppCallsWebApi(Configuration, new string[] { Constants.ScopeUserRead })
105+
.AddInMemoryTokenCaches();
110106
```
111107

112108
The two new lines of code:

2-WebApp-graph-user/2-1-Call-MSGraph/Startup.cs

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,12 @@ public void ConfigureServices(IServiceCollection services)
4040

4141
services.AddOptions();
4242

43-
services.AddAuthentication(OpenIdConnectDefaults.AuthenticationScheme)
44-
.AddMicrosoftWebApp(Configuration)
45-
46-
// Token acquisition service based on MSAL.NET
47-
// and chosen token cache implementation
48-
.AddMicrosoftWebAppCallsWebApi(Configuration, new string[] { Constants.ScopeUserRead });
49-
services.AddInMemoryTokenCaches();
50-
43+
services.AddMicrosoftWebAppAuthentication(Configuration)
44+
.AddMicrosoftWebAppCallsWebApi(Configuration, new string[] { Constants.ScopeUserRead })
45+
.AddInMemoryTokenCaches();
5146
/*
5247
// or use a distributed Token Cache by adding
53-
.AddDistributedTokenCaches();
48+
.AddDistributedTokenCaches();
5449
5550
// and then choose your implementation.
5651
// See https://docs.microsoft.com/en-us/aspnet/core/performance/caching/distributed?view=aspnetcore-2.2#distributed-memory-cache
@@ -112,11 +107,11 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
112107

113108
app.UseEndpoints(endpoints =>
114109
{
115-
endpoints.MapControllerRoute(
116-
name: "default",
117-
pattern: "{controller=Home}/{action=Index}/{id?}");
118-
endpoints.MapRazorPages();
119-
});
110+
endpoints.MapControllerRoute(
111+
name: "default",
112+
pattern: "{controller=Home}/{action=Index}/{id?}");
113+
endpoints.MapRazorPages();
114+
});
120115
}
121116
}
122117
}

2-WebApp-graph-user/2-2-TokenCache/README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,10 +187,8 @@ public void ConfigureServices(IServiceCollection services)
187187
. . .
188188
services.AddAuthentication(OpenIdConnectDefaults.AuthenticationScheme)
189189
.AddMicrosoftWebApp(Configuration)
190-
// Token acquisition service based on MSAL.NET
191-
// and chosen token cache implementation
192-
.AddMicrosoftWebAppCallsWebApi(Configuration, new string[] { Constants.ScopeUserRead });
193-
services.AddDistributedTokenCaches();
190+
.AddMicrosoftWebAppCallsWebApi(Configuration, new string[] { Constants.ScopeUserRead })
191+
.AddDistributedTokenCaches();
194192

195193
services.AddDistributedSqlServerCache(options =>
196194
{

2-WebApp-graph-user/2-2-TokenCache/Startup.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,8 @@ dotnet tool install --global dotnet-sql-cache
5353

5454
services.AddAuthentication(OpenIdConnectDefaults.AuthenticationScheme)
5555
.AddMicrosoftWebApp(Configuration)
56-
57-
// Token acquisition service based on MSAL.NET
58-
// and chosen token cache implementation
59-
.AddMicrosoftWebAppCallsWebApi(Configuration, new string[] { Constants.ScopeUserRead });
60-
services.AddDistributedTokenCaches();
56+
.AddMicrosoftWebAppCallsWebApi(Configuration, new string[] { Constants.ScopeUserRead })
57+
.AddDistributedTokenCaches();
6158

6259
services.AddDistributedSqlServerCache(options =>
6360
{

2-WebApp-graph-user/2-3-Multi-Tenant/README-National-Cloud.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ The `https://graph.microsoft.com/.default` is a static scope that allows the ten
273273

274274
### Custom token validation allowing only registered tenants
275275

276-
On the `Startup.cs` we are calling `AddMicrosoftWebApp` to configure the authentication, and within that method, we validates that the token issuer is from AAD.
276+
On the `Startup.cs` we are calling `AddMicrosoftWebAppAuthentication` to configure the authentication, and within that method, we validates that the token issuer is from AAD.
277277

278278
```csharp
279279
options.TokenValidationParameters.IssuerValidator = AadIssuerValidator.GetIssuerValidator(options.Authority).Validate;

2-WebApp-graph-user/2-3-Multi-Tenant/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ The `https://graph.microsoft.com/.default` is a static scope that allows the ten
249249

250250
### Custom token validation allowing only registered tenants
251251

252-
On the `Startup.cs` we are calling `AddMicrosoftWebApp` to configure the authentication, and within that method, we validates that the token issuer is from AAD.
252+
On the `Startup.cs` we are calling `AddMicrosoftWebAppAuthentication` to configure the authentication, and within that method, we validates that the token issuer is from AAD.
253253

254254
```csharp
255255
options.TokenValidationParameters.IssuerValidator = AadIssuerValidator.GetIssuerValidator(options.Authority).Validate;

2-WebApp-graph-user/2-3-Multi-Tenant/Startup.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,10 @@ public void ConfigureServices(IServiceCollection services)
8585
return Task.FromResult(0);
8686
};
8787
}, options =>
88-
{
89-
Configuration.Bind("AzureAD", options);
90-
}, options =>
9188
{
9289
})
93-
94-
.AddMicrosoftWebAppCallsWebApi(Configuration, new string[] { GraphScope.UserReadAll });
95-
services.AddInMemoryTokenCaches();
90+
.AddMicrosoftWebAppCallsWebApi(Configuration, new string[] { GraphScope.UserReadAll })
91+
.AddInMemoryTokenCaches();
9692

9793
services.AddControllersWithViews(options =>
9894
{

3-WebApp-multi-APIs/README.md

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,19 +76,15 @@ Starting from the [previous phase of the tutorial](../../2-WebApp-graph-user/2-1
7676

7777
### Update the `Startup.cs` file to enable TokenAcquisition by a MSAL.NET based service
7878

79-
After the following lines in the ConfigureServices(IServiceCollection services) method, after `services.AddMicrosoftWebApp(Configuration);`, add `services.AddHttpClient<IArmOperations, ArmApiOperationService>();`:
79+
After the following lines in the ConfigureServices(IServiceCollection services) method, after `services.AddMicrosoftWebAppAuthentication(Configuration);`, add `services.AddHttpClient<IArmOperations, ArmApiOperationService>();`:
8080

8181
```CSharp
8282
public void ConfigureServices(IServiceCollection services)
8383
{
8484
. . .
85-
services.AddAuthentication(OpenIdConnectDefaults.AuthenticationScheme)
86-
.AddMicrosoftWebApp(Configuration)
87-
88-
// Token acquisition service based on MSAL.NET
89-
// and chosen token cache implementation
90-
.AddMicrosoftWebAppCallsWebApi(Configuration, new string[] { Constants.ScopeUserRead });
91-
services.AddInMemoryTokenCaches();
85+
services.AddMicrosoftWebAppAuthentication(Configuration)
86+
.AddMicrosoftWebAppCallsWebApi(Configuration, new string[] { Constants.ScopeUserRead })
87+
.AddInMemoryTokenCaches();
9288
services.AddHttpClient<IArmOperations, ArmApiOperationService>();
9389
```
9490

0 commit comments

Comments
 (0)