-
Notifications
You must be signed in to change notification settings - Fork 212
refactor: PR 1.4 migrate to jwx v3 and implement pure options for JWKS provider #358
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
Open
developerkunal
wants to merge
6
commits into
v3-phase1-pr3-validator-options
Choose a base branch
from
v3-phase1-pr4-jwx-migration
base: v3-phase1-pr3-validator-options
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
refactor: PR 1.4 migrate to jwx v3 and implement pure options for JWKS provider #358
developerkunal
wants to merge
6
commits into
v3-phase1-pr3-validator-options
from
v3-phase1-pr4-jwx-migration
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Replaces go-jose with lestrrat-go/jwx v3.0.12 for JWT operations and introduces improved issuer, audience and JWKS handling. Major changes: - Replace go-jose with lestrrat-go/jwx v3.0.12 for JWT handling - Add ES256K algorithm support (ECDSA with secp256k1 curve) - Implement multi-issuer support through WithIssuer and WithIssuers - Simplify JWKS provider using jwx's built-in cache which reduces code size by about sixty percent - Add manual issuer and audience validation to support multiple values Status: - Validator and JWKS packages build successfully - Eighteen of twenty-eight validator tests are passing which confirms that all successful validation paths work - Ten tests require updates to expected error messages and are currently in progress
…test coverage - Refactor jwks.NewProvider() and jwks.NewCachingProvider() to pure options pattern - Remove positional parameters, all configuration via functional options - Implement runtime type switching to accept both ProviderOption and CachingProviderOption - Fix race condition in cache implementation with proper lock synchronization - Add URL validation to validator.WithIssuers() for consistency - Improve test coverage: jwks 92.1% (+4.8%), validator 87.0% (+5.2%) - Add comprehensive tests for all signature algorithms (EdDSA, HS256/384/512, RS256/384/512, ES256/384/512/ES256K, PS256/384/512) - Update examples/http-jwks-example to use pure options API - Document and skip pre-existing test failure in http-jwks-example Breaking Changes: - NewCachingProvider now accepts options only (no positional params) - WithIssuers now validates URL format and returns errors for invalid URLs Fixes: - Race condition in jwxCache.Get() with concurrent goroutines - Missing URL validation in WithIssuers option All tests pass with race detection enabled.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## v3-phase1-pr3-validator-options #358 +/- ##
===================================================================
+ Coverage 97.95% 99.46% +1.50%
===================================================================
Files 13 13
Lines 441 562 +121
===================================================================
+ Hits 432 559 +127
+ Misses 6 3 -3
+ Partials 3 0 -3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This was referenced Nov 21, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
📝 Checklist
🔧 Changes
This PR migrates JWT handling from go-jose v2 to lestrrat-go/jwx v3 and refactors JWKS provider to use pure options pattern.
JWT Library Migration
gopkg.in/go-jose/go-jose.v2togithub.com/lestrrat-go/jwx/v3Pure Options Pattern for JWKS Provider
jwks.NewProvider()andjwks.NewCachingProvider()to pure options patternNew Options API:
WithIssuerURL(*url.URL)- required, sets the issuer URL for OIDC discoveryWithCustomJWKSURI(*url.URL)- optional, bypasses discovery and uses custom JWKS endpointWithCustomClient(*http.Client)- optional, uses custom HTTP clientWithCacheTTL(time.Duration)- CachingProvider only, sets cache TTL (default: 15 minutes)WithCache(Cache)- CachingProvider only, uses custom cache implementationBug Fixes
validator.WithIssuersfor consistency withWithIssuerTesting & Examples
Breaking Changes
jwks.NewProvider()andjwks.NewCachingProvider()now return(*Provider, error)instead of*ProviderMigration Example:
📚 References
Part of v3 refactoring series:
🔬 Testing
All tests pass with race detection:
Manual Testing:
cd examples/http-example && go run main.gocd examples/http-jwks-example && go run main.go