-
Notifications
You must be signed in to change notification settings - Fork 413
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ability to exclude default header claims when creating token #2979
base: dev
Are you sure you want to change the base?
Conversation
Is there an issue tracking this? |
Not at the moment. This was just something discussed since we wanted to remove |
SummarySummary
CoverageMicrosoft.IdentityModel.Abstractions - 70.2%
Microsoft.IdentityModel.JsonWebTokens - 80%
Microsoft.IdentityModel.Logging - 74.5%
Microsoft.IdentityModel.Protocols - 88.2%
Microsoft.IdentityModel.Protocols.OpenIdConnect - 81.4%
Microsoft.IdentityModel.Protocols.SignedHttpRequest - 93.4%
Microsoft.IdentityModel.Protocols.Tests - 0%
Microsoft.IdentityModel.Protocols.WsFederation - 80.9%
Microsoft.IdentityModel.TestUtils - 87%
Microsoft.IdentityModel.Tokens - 75.9%
Microsoft.IdentityModel.Tokens.Saml - 71.1%
Microsoft.IdentityModel.Tokens.Tests - 4.6%
Microsoft.IdentityModel.Validators - 95.8%
Microsoft.IdentityModel.Xml - 79.3%
System.IdentityModel.Tokens.Jwt - 84%
System.IdentityModel.Tokens.Jwt.Tests - 20.1%
|
src/Microsoft.IdentityModel.JsonWebTokens/JsonWebTokenHandler.CreateToken.cs
Show resolved
Hide resolved
/// The default header claims are 'alg', 'kid', 'x5t', 'enc', and 'zip'. | ||
/// </remarks> | ||
#pragma warning disable CA2227 // Collection properties should be read only | ||
public ISet<string> ExcludedDefaultHeaderClaims { get; set; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general, Exclude APIs are not common in Identity Model. What are the alternatives that we considered?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think any others were considered. I proposed this since only excluding kid
and x5t
was very targeted and iffy, and the only other option that comes to mind is allocating a set with all the default header claims in every SecurityTokenDescriptor
which can be modified as desired, but then you end up with those allocations.
94f421a
to
a460730
Compare
a460730
to
887b216
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thanks @msbw2
887b216
to
6a61dbe
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 5 out of 8 changed files in this pull request and generated no comments.
Files not reviewed (3)
- src/Microsoft.IdentityModel.JsonWebTokens/InternalAPI.Unshipped.txt: Language not supported
- src/Microsoft.IdentityModel.Tokens/PublicAPI.Unshipped.txt: Language not supported
- src/System.IdentityModel.Tokens.Jwt/InternalAPI.Unshipped.txt: Language not supported
Comments suppressed due to low confidence (3)
src/Microsoft.IdentityModel.Tokens/SecurityTokenDescriptor.cs:124
- The comment should end with a period for consistency.
/// Indicates if <c>kid</c> and <c>x5t</c> should be included in the header of a JSON web token (JWT)
src/Microsoft.IdentityModel.JsonWebTokens/JsonWebTokenHandler.CreateToken.cs:881
- [nitpick] The method name 'IncludeDefaultHeaderClaim' is ambiguous. It should be renamed to 'ShouldIncludeDefaultHeaderClaim'.
internal static bool IncludeDefaultHeaderClaim(string claim, ISet<string> excludedDefaultHeaderClaims) =>
src/Microsoft.IdentityModel.JsonWebTokens/JsonWebTokenHandler.CreateToken.cs:1045
- The comment on this line should use 'compression algorithm' instead of 'compressionAlgorithm' for better readability.
if (!string.IsNullOrEmpty(compressionAlgorithm) && IncludeDefaultHeaderClaim(JwtHeaderParameterNames.Zip, excludedDefaultHeaderClaims))
Add ability to exclude default header claims when creating token.