Skip to content

Commit

Permalink
return CaseSensitiveClaimsIdentity in clone (#2879)
Browse files Browse the repository at this point in the history
* return CaseSensitiveClaimsIdentity in clone

* update public API
  • Loading branch information
jennyf19 authored Oct 8, 2024
1 parent 3bb0316 commit e88c97a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,14 @@ public override bool HasClaim(string type, string value)
return base.HasClaim(claim => claim?.Type.Equals(type, StringComparison.Ordinal) == true
&& claim?.Value.Equals(value, StringComparison.Ordinal) == true);
}

/// <inheritdoc/>
public override ClaimsIdentity Clone()
{
CaseSensitiveClaimsIdentity claimsIdentity = new(this);

return claimsIdentity;
}
}

#pragma warning disable RS0030 // Do not use banned APIs
Expand Down
1 change: 1 addition & 0 deletions src/Microsoft.IdentityModel.Tokens/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -749,6 +749,7 @@ override Microsoft.IdentityModel.Tokens.AsymmetricSignatureProvider.Sign(byte[]
override Microsoft.IdentityModel.Tokens.AsymmetricSignatureProvider.Sign(byte[] input, int offset, int count) -> byte[]
override Microsoft.IdentityModel.Tokens.AsymmetricSignatureProvider.Verify(byte[] input, byte[] signature) -> bool
override Microsoft.IdentityModel.Tokens.AsymmetricSignatureProvider.Verify(byte[] input, int inputOffset, int inputLength, byte[] signature, int signatureOffset, int signatureLength) -> bool
override Microsoft.IdentityModel.Tokens.CaseSensitiveClaimsIdentity.Clone() -> System.Security.Claims.ClaimsIdentity
override Microsoft.IdentityModel.Tokens.CaseSensitiveClaimsIdentity.FindAll(string type) -> System.Collections.Generic.IEnumerable<System.Security.Claims.Claim>
override Microsoft.IdentityModel.Tokens.CaseSensitiveClaimsIdentity.FindFirst(string type) -> System.Security.Claims.Claim
override Microsoft.IdentityModel.Tokens.CaseSensitiveClaimsIdentity.HasClaim(string type, string value) -> bool
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,15 @@ public void DefaultProperties_CorrectlySet()
Assert.Equal(validationParameters.RoleClaimType, claimsIdentity.RoleClaimType);
}

[Fact]
public void Clone_ReturnsCaseSensitiveClaimsIdentity()
{
var claimsIdentity = new CaseSensitiveClaimsIdentity();
var clone = claimsIdentity.Clone();

Assert.True(clone is CaseSensitiveClaimsIdentity);
}

public static TheoryData<CaseSensitiveClaimsIdentityTheoryData> GetCaseSensitiveClaimsIdentityTheoryData
{
get
Expand Down

0 comments on commit e88c97a

Please sign in to comment.