Skip to content

Conversation

@cmmoran
Copy link

@cmmoran cmmoran commented Jul 25, 2024

Note: I'm on a time-crunch and decided at the last minute to open a PR instead of "going it alone". I'll circle back and flesh this out more when I have spare time (... as if that will ever truly be the case...)

Support multiple issuer:audience combinations by introducing an option for the expectedClaims. WithExpectedClaims can be called with multiple jwt.Expected parameters to allow different Issuer:Audience combinations to validate tokens

feat: support multiple issuers in a provider using WithAdditionalIssuers option

Every effort has been made to ensure backwards compatibility. Some error messages will be different due to the wrapping of errors when multiple jwt.Expected are set. When validating the jwt, if an error is encountered, instead of returning immediately, the current error is wrapped. This is good and bad. Good because all verification failure causes are captured in a single wrapped error; Bad because all verification failure causes are captured in a single monolithic wrapped error. Unwrapping the error can be tedious if many jwt.Expected are included. There is likely a better way but this suits my purposes.

A few more test cases may be needed in order to achieve true confidence in this change

📝 Checklist

  • All new/changed/fixed functionality is covered by tests (or N/A)
  • I have added documentation for all new/changed functionality (or N/A)

🔧 Changes

Notable change is the upgrade from jose/v2 to jose/v4. While the change is technically a breaking change, I included it in this PR because this fork is in use in production and jose/v2 conflicted with our current set of libraries.

📚 References

#197
#269

🔬 Testing

@cmmoran cmmoran force-pushed the feat/jwt-multiple-issuer-validation branch 2 times, most recently from 0977eb4 to 0463741 Compare November 9, 2024 09:53
@cmmoran cmmoran marked this pull request as ready for review November 9, 2024 11:08
@cmmoran cmmoran requested a review from a team as a code owner November 9, 2024 11:08
@cmmoran cmmoran force-pushed the feat/jwt-multiple-issuer-validation branch from 4a25c8c to 24d743e Compare December 20, 2024 10:41
… option for the expectedClaims. WithExpectedClaims can be called with multiple jwt.Expected parameters to allow different Issuer:Audience combinations to validate tokens

feat: support multiple issuers in a provider using WithAdditionalIssuers option

Every effort has been made to ensure backwards compatibility. Some error messages will be different due to the wrapping of errors when multiple jwt.Expected are set. When validating the jwt, if an error is encountered, instead of returning immediately, the current error is wrapped. This is good and bad. Good because all verification failure causes are captured in a single wrapped error; Bad because all verification failure causes are captured in a single monolithic wrapped error. Unwrapping the error can be tedious if many jwt.Expected are included. There is likely a better way but this suits my purposes.

A few more test cases will likely be needed in order to achieve true confidence in this change
@cmmoran cmmoran force-pushed the feat/jwt-multiple-issuer-validation branch from 24d743e to 18fa23a Compare September 2, 2025 09:56
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.

1 participant