← 输入框|github.com|刷新
Skip to content

Migrate JWT verification from jwx v2 to v4 - #470

Merged
j127 merged 1 commit into
mainfrom
claude/jwx-v4
Nov 23, 2026
Merged

j127 merged 1 commit into
mainfrom
claude/jwx-v4

Conversation

@j127

@j127 j127 commented Nov 23, 2026

Copy link
Copy Markdown
Member

github.com/lestrrat-go/jwx/v2 is 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

  • Imports move from jwx/v2 to jwx/v4. Token claims use the v4 accessors (Subject() and friends now also return a present flag, and Get became Field). Tests use jwk.Import[jwk.Key] and jwa.RS256().
  • The background JWKS cache moved out of core jwx into the github.com/jwx-go/jwkfetch/v4 companion, backed by httprc/v3. The 15-minute minimum refresh interval is unchanged.
  • Startup behavior kept fail-fast. jwkfetch.Cache.Register waits for the first successful fetch by default, which would make Start hang (not fail) while the WorkOS JWKS endpoint is down. The verifier registers with WithWaitReady(false) and keeps the synchronous priming Refresh, so Start still returns the error. The new TestStartFailsFastOnJWKSServerError uses a 30s deadline and fails if Start blocks. I checked that it fails without the fix.
  • Go 1.27 minimum. v4 needs Go 1.27, or GOEXPERIMENT=jsonv2 on 1.26, so go.mod and the README now say 1.27.

Checks run locally (Go 1.27.4)

go test -race ./..., go vet ./..., and govulncheck (no vulnerabilities).

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.
@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Explain Change →

Caution

Review failed

The pull request is closed.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

@j127
j127 changed the base branch from claude/dependency-updates-570d50 to main November 23, 2026 03:14
@j127
j127 merged commit eaedddb into main Nov 23, 2026
2 checks passed
@j127
j127 deleted the claude/jwx-v4 branch November 23, 2026 03:17
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