Skip to content

Commit

Permalink
Add a new way of claims mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
damienbod committed Nov 5, 2023
1 parent ee33bf0 commit 441cc6b
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions WebCodeFlowPkceClient/HostingExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.AspNetCore.Authentication.OpenIdConnect;
using Microsoft.IdentityModel.JsonWebTokens;
using Microsoft.IdentityModel.Logging;
using Serilog;
using System.IdentityModel.Tokens.Jwt;
//using System.IdentityModel.Tokens.Jwt;

namespace WebCodeFlowPkceClient;

Expand Down Expand Up @@ -40,6 +41,7 @@ public static WebApplication ConfigureServices(this WebApplicationBuilder builde
options.GetClaimsFromUserInfoEndpoint = true;
options.ClaimActions.MapUniqueJsonKey("preferred_username", "preferred_username");
options.ClaimActions.MapUniqueJsonKey("gender", "gender");
options.MapInboundClaims = false;
});

services.AddAuthorization();
Expand All @@ -50,8 +52,9 @@ public static WebApplication ConfigureServices(this WebApplicationBuilder builde

public static WebApplication ConfigurePipeline(this WebApplication app)
{
IdentityModelEventSource.ShowPII = true;
JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear();
//IdentityModelEventSource.ShowPII = true;
//JsonWebTokenHandler.DefaultInboundClaimTypeMap.Clear(); // .NET 8
//JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear();

app.UseSerilogRequestLogging();

Expand Down

0 comments on commit 441cc6b

Please sign in to comment.