Skip to content
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 audiences to security token descriptor #2575

Merged
merged 75 commits into from
Jun 22, 2024

Conversation

JoshLozensky
Copy link
Contributor

@JoshLozensky JoshLozensky commented Apr 30, 2024

Added SecurityTokenDescriptor.Audiences member.

Description

Enabling customers to easily add multiple Audiences to the Aud claim in accordance with the JSON Web Token RFC (7519 section 4.1.3)

  • Added SecurityTokenDescriptor.Audiences member and adjusted logic to support customers using it instead of or in addition to SecurityTokenDescriptor.Audience. Some of the code is designed to be removed once we deprecate SecurityTokenDescriptor.Audience as noted in the code comments.
  • Added logic and unit tests to 4 flows to support the new member:
    • JwtSecurityTokenHandler
    • JsonWebTokenHandler
    • SamlSecurityTokenHandler
    • and Saml2SecurityTokenHandler.
  • Created 3 new benchmark tests to assess impact of the new member and design choices

Benchmark Results:

The increase in allocation and time taken when using multiple audiences is partly expected, it takes longer to work with multiple strings than a single string.

Method Mean Error StdDev Median P90 P95 P100 Allocated
Dev-JsonWebTokenHandler_CreateToken 628.6 us 0.91 us 1.95 us not given 630.6 us 631.9 us 636.5 us 7.02 KB
PR-JsonWebTokenHandler_CreateToken 626.4 us 0.61 us 1.28 us 626.1 us 627.9 us 629.1 us 631.2 us 7.02 KB
PR-..._SingleAudienceUsingAudiencesMemberOnly 625.7 us 0.52 us 1.12 us 625.3 us 627.1 us 627.7 us 628.4 us 7.08 KB
PR-..._MultipleAudiencesMemberOnly 625.2 us 0.33 us 0.69 us 625.2 us 625.9 us 626.5 us 627.6 us 8.02 KB
PR-..._MultipleAudiencesMemberAndClaims 625.7 us 0.50 us 1.05 us 625.4 us 627.0 us 627.8 us 628.7 us 8.02 KB

Fixes #1479

@JoshLozensky JoshLozensky marked this pull request as ready for review May 14, 2024 20:08
@JoshLozensky JoshLozensky requested a review from a team as a code owner May 14, 2024 20:08
@JoshLozensky JoshLozensky changed the title Lozensky/add audiences to security token descriptor Add audiences to security token descriptor Jun 19, 2024
@brentschmaltz brentschmaltz merged commit 55cc10e into dev Jun 22, 2024
4 checks passed
@JoshLozensky JoshLozensky deleted the lozensky/AddAudiencesToSecurityTokenDescriptor branch June 22, 2024 01:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SecurityTokenDescriptor Audience is a string, but is should be an array of strings.
5 participants