Skip to content

Commit

Permalink
Revert "Set DefaultMapInboundClaims to false to keep roles claim type" (
Browse files Browse the repository at this point in the history
#3293)

Revert "Set DefaultMapInboundClaims to false to keep roles claim type (#3281)"

This reverts commit da87dc2.
  • Loading branch information
bcarthic authored Jan 9, 2024
1 parent faf3187 commit ba723a8
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions src/Microsoft.Health.Dicom.Api/Modules/SecurityModule.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// -------------------------------------------------------------------------------------------------
// -------------------------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information.
// -------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -37,13 +37,7 @@ public void Load(IServiceCollection services)
EnsureArg.IsNotNull(services, nameof(services));

// Set the token handler to not do auto inbound mapping. (e.g. "roles" -> "http://schemas.microsoft.com/ws/2008/06/identity/claims/role")
// The JWT security token handler has a new property MapInboundClaims which is set to true by default.
// When this property is true, it maps some claim types to Microsoft's proprietary ones.
// This includes mapping the standard JWT "roles" claim to ClaimTypes.Role.
// If you want to keep the "roles" claim as is, you need to set MapInboundClaims to false
// In .Net 7, JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear(); works
// Im .Net 8. JwtSecurityTokenHandler.DefaultMapInboundClaims = false; works
JwtSecurityTokenHandler.DefaultMapInboundClaims = false;
JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear();

if (_securityConfiguration.Enabled)
{
Expand Down

0 comments on commit ba723a8

Please sign in to comment.