From 2f6ed1ed4a31b372fdea41bbaba0284a58a14903 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Chalet?= Date: Mon, 20 Dec 2021 18:09:36 +0100 Subject: [PATCH] Use the OpenIdConnectOptions.MapInboundClaims API introduced in ASP.NET Core 5.0 --- samples/Mvc.Client/Startup.cs | 16 +++++++--------- samples/Mvc.Server/Startup.cs | 8 +++++--- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/samples/Mvc.Client/Startup.cs b/samples/Mvc.Client/Startup.cs index bc07e9ad..74eb9a74 100644 --- a/samples/Mvc.Client/Startup.cs +++ b/samples/Mvc.Client/Startup.cs @@ -1,4 +1,3 @@ -using System.IdentityModel.Tokens.Jwt; using Microsoft.AspNetCore.Authentication.Cookies; using Microsoft.AspNetCore.Authentication.OpenIdConnect; using Microsoft.IdentityModel.Protocols.OpenIdConnect; @@ -46,11 +45,8 @@ public class Startup options.Scope.Add("offline_access"); options.Scope.Add("demo_api"); - options.SecurityTokenValidator = new JwtSecurityTokenHandler - { - // Disable the built-in JWT claims mapping feature. - InboundClaimTypeMap = new Dictionary() - }; + // Disable the built-in JWT claims mapping feature. + options.MapInboundClaims = false; options.TokenValidationParameters.NameClaimType = "name"; options.TokenValidationParameters.RoleClaimType = "role"; @@ -74,8 +70,10 @@ public class Startup app.UseAuthentication(); app.UseAuthorization(); - app.UseEndpoints(options => options.MapControllerRoute( - name: "default", - pattern: "{controller=Home}/{action=Index}/{id?}")); + app.UseEndpoints(options => + { + options.MapControllers(); + options.MapDefaultControllerRoute(); + }); } } diff --git a/samples/Mvc.Server/Startup.cs b/samples/Mvc.Server/Startup.cs index 2e3dad5f..8b0ff97a 100644 --- a/samples/Mvc.Server/Startup.cs +++ b/samples/Mvc.Server/Startup.cs @@ -189,8 +189,10 @@ public class Startup app.UseAuthentication(); app.UseAuthorization(); - app.UseEndpoints(options => options.MapControllerRoute( - name: "default", - pattern: "{controller=Home}/{action=Index}/{id?}")); + app.UseEndpoints(options => + { + options.MapControllers(); + options.MapDefaultControllerRoute(); + }); } }