Repository navigation
Migrate JWT verification from jwx v2 to v4 - #470
Merged
Merged
Conversation
jwx v2 is deprecated and no longer maintained. v4 moves the background JWKS cache into the jwx-go/jwkfetch companion, so the verifier now builds a jwkfetch.Cache on an httprc client. The cache's Register waits for the first successful fetch by default, which would hang server startup instead of failing it when the WorkOS JWKS endpoint is down. Register without waiting and keep the synchronous priming Refresh so Start still returns that error, with a test that fails if Start blocks until its deadline. v4 needs Go 1.27 (or GOEXPERIMENT=jsonv2 on 1.26), so the go.mod minimum and README move to 1.27.
|
Caution Review failedThe pull request is closed.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
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
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.
github.com/lestrrat-go/jwx/v2is deprecated and no longer maintained, so this moves the WorkOS JWT verification to v4.Stacked on #469 (it needs that PR's Go 1.27 toolchain). Merge #469 first; GitHub then retargets this PR to
main.Changes
jwx/v2tojwx/v4. Token claims use the v4 accessors (Subject()and friends now also return a present flag, andGetbecameField). Tests usejwk.Import[jwk.Key]andjwa.RS256().github.com/jwx-go/jwkfetch/v4companion, backed byhttprc/v3. The 15-minute minimum refresh interval is unchanged.jwkfetch.Cache.Registerwaits for the first successful fetch by default, which would makeStarthang (not fail) while the WorkOS JWKS endpoint is down. The verifier registers withWithWaitReady(false)and keeps the synchronous primingRefresh, soStartstill returns the error. The newTestStartFailsFastOnJWKSServerErroruses a 30s deadline and fails ifStartblocks. I checked that it fails without the fix.GOEXPERIMENT=jsonv2on 1.26, sogo.modand the README now say 1.27.Checks run locally (Go 1.27.4)
go test -race ./...,go vet ./..., and govulncheck (no vulnerabilities).