From ae54086ae993d17cf884cf0a719fa3f1bd0c65a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Chalet?= Date: Wed, 20 Sep 2017 15:00:24 +0200 Subject: [PATCH] Disable the built-in OIDC claims mapping feature in the MVC sample --- samples/Mvc.Client/Startup.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/samples/Mvc.Client/Startup.cs b/samples/Mvc.Client/Startup.cs index 02206b22..668d2f09 100644 --- a/samples/Mvc.Client/Startup.cs +++ b/samples/Mvc.Client/Startup.cs @@ -1,3 +1,5 @@ +using System.Collections.Generic; +using System.IdentityModel.Tokens.Jwt; using System.Net.Http; using Microsoft.AspNetCore.Authentication.Cookies; using Microsoft.AspNetCore.Authentication.OpenIdConnect; @@ -45,6 +47,15 @@ namespace Mvc.Client options.Scope.Add("email"); options.Scope.Add("roles"); options.Scope.Add("offline_access"); + + options.SecurityTokenValidator = new JwtSecurityTokenHandler + { + // Disable the built-in JWT claims mapping feature. + InboundClaimTypeMap = new Dictionary() + }; + + options.TokenValidationParameters.NameClaimType = "name"; + options.TokenValidationParameters.RoleClaimType = "role"; }); services.AddMvc();