Skip to content

Commit 9712d15

Browse files
author
Brent Schmaltz
committed
adjust for claims mapping
remove using System
1 parent b4fe386 commit 9712d15

File tree

4 files changed

+11
-7
lines changed

4 files changed

+11
-7
lines changed

src/Security/Authentication/JwtBearer/src/JwtBearerHandler.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4-
using System;
54
using System.Globalization;
65
using System.Linq;
76
using System.Security.Claims;

src/Security/Authentication/JwtBearer/src/JwtBearerOptions.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public class JwtBearerOptions : AuthenticationSchemeOptions
1717
{
1818
private readonly JwtSecurityTokenHandler _defaultHandler = new JwtSecurityTokenHandler();
1919
private readonly JsonWebTokenHandler _defaultTokenHandler = new JsonWebTokenHandler();
20+
private bool _mapInboundClaims = JwtSecurityTokenHandler.DefaultMapInboundClaims;
2021

2122
/// <summary>
2223
/// Initializes a new instance of <see cref="JwtBearerOptions"/>.
@@ -135,15 +136,20 @@ public JwtBearerOptions()
135136
public bool IncludeErrorDetails { get; set; } = true;
136137

137138
/// <summary>
138-
/// Gets or sets the <see cref="MapInboundClaims"/> property on the default instance of <see cref="JwtSecurityTokenHandler"/> in SecurityTokenValidators, which is used when determining
139-
/// whether or not to map claim types that are extracted when validating a <see cref="JwtSecurityToken"/>.
139+
/// Gets or sets the <see cref="MapInboundClaims"/> property on the default instance of <see cref="JwtSecurityTokenHandler"/> in SecurityTokenValidators, or <see cref="JsonWebTokenHandler"/>which is used when determining
140+
/// whether or not to map claim types that are extracted when validating a <see cref="JwtSecurityToken"/> or <see cref="JsonWebToken"/>.
140141
/// <para>If this is set to true, the Claim Type is set to the JSON claim 'name' after translating using this mapping. Otherwise, no mapping occurs.</para>
141142
/// <para>The default value is true.</para>
142143
/// </summary>
143144
public bool MapInboundClaims
144145
{
145-
get => _defaultHandler.MapInboundClaims;
146-
set => _defaultHandler.MapInboundClaims = value;
146+
get => _mapInboundClaims;
147+
set
148+
{
149+
_mapInboundClaims = value;
150+
_defaultHandler.MapInboundClaims = value;
151+
_defaultTokenHandler.MapInboundClaims = value;
152+
}
147153
}
148154

149155
/// <summary>

src/Security/Authentication/WsFederation/src/WsFederationHandler.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4-
using System;
54
using System.Linq;
65
using System.Security.Claims;
76
using System.Text.Encodings.Web;

src/Security/Authentication/WsFederation/src/WsFederationOptions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public class WsFederationOptions : RemoteAuthenticationOptions
3030
{
3131
new Saml2SecurityTokenHandler(),
3232
new SamlSecurityTokenHandler(),
33-
new JsonWebTokenHandler()
33+
new JsonWebTokenHandler(){ MapInboundClaims = true }
3434
};
3535

3636
private TokenValidationParameters _tokenValidationParameters = new TokenValidationParameters();

0 commit comments

Comments
 (0)