Skip to content

Commit f23b270

Browse files
author
Tiago Brenck
committed
Fixes for step 4:
- Removed DefaultMapInboundClaims - Removed miss configuration on WebApiServiceCollectionExtensions - Added token cache for web api
1 parent 12e5980 commit f23b270

File tree

3 files changed

+5
-8
lines changed

3 files changed

+5
-8
lines changed

4-WebApp-your-API/Client/Startup.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public void ConfigureServices(IServiceCollection services)
4040
// By default, the claims mapping will map claim names in the old format to accommodate older SAML applications.
4141
// 'http://schemas.microsoft.com/ws/2008/06/identity/claims/role' instead of 'roles'
4242
// This flag ensures that the ClaimsIdentity claims collection will be built from the claims in the token
43-
JwtSecurityTokenHandler.DefaultMapInboundClaims = false;
43+
//JwtSecurityTokenHandler.DefaultMapInboundClaims = false;
4444

4545
// Token acquisition service based on MSAL.NET
4646
// and chosen token cache implementation

4-WebApp-your-API/TodoListService/Startup.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,10 @@ public void ConfigureServices(IServiceCollection services)
5151
// By default, the claims mapping will map claim names in the old format to accommodate older SAML applications.
5252
// 'http://schemas.microsoft.com/ws/2008/06/identity/claims/role' instead of 'roles'
5353
// This flag ensures that the ClaimsIdentity claims collection will be built from the claims in the token
54-
JwtSecurityTokenHandler.DefaultMapInboundClaims = false;
54+
//JwtSecurityTokenHandler.DefaultMapInboundClaims = false;
5555

56-
services.AddProtectedWebApi(Configuration);
57-
services.Configure<JwtBearerOptions>(AzureADDefaults.JwtBearerAuthenticationScheme, options =>
58-
{
59-
options.TokenValidationParameters.NameClaimType = "name";
60-
});
56+
services.AddProtectedWebApi(Configuration)
57+
.AddInMemoryTokenCaches();
6158

6259
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
6360
}

Microsoft.Identity.Web/WebApiServiceCollectionExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public static IServiceCollection AddProtectedWebApi(
4141
string configSectionName = "AzureAD",
4242
bool subscribeToJwtBearerMiddlewareDiagnosticsEvents = false)
4343
{
44-
services.Configure<AzureADOptions>(options => configuration.Bind(configSectionName, options));
44+
//services.Configure<AzureADOptions>(options => configuration.Bind(configSectionName, options));
4545
services.AddAuthentication(AzureADDefaults.JwtBearerAuthenticationScheme)
4646
.AddAzureADBearer(options => configuration.Bind(configSectionName, options));
4747

0 commit comments

Comments
 (0)