Repository navigation
fix(backend): Accept RSA jwtKey of any size (Core 2) - #11108
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
🦋 Changeset detectedLatest commit: 1e54b6a The changes in this PR will be included in the next version bump. This PR includes changesets to release 11 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
|
@clerk/agent-toolkit
@clerk/astro
@clerk/backend
@clerk/chrome-extension
@clerk/clerk-js
@clerk/dev-cli
@clerk/elements
@clerk/clerk-expo
@clerk/expo-passkeys
@clerk/express
@clerk/fastify
@clerk/localizations
@clerk/nextjs
@clerk/nuxt
@clerk/clerk-react
@clerk/react-router
@clerk/remix
@clerk/shared
@clerk/tanstack-react-start
@clerk/testing
@clerk/themes
@clerk/types
@clerk/upgrade
@clerk/vue
commit: |


Summary
jwtKey/CLERK_JWT_KEYaccepts an RSA public key of any size, such as 3072-bit. ES256 support and the JWKS fallback from #11037 are unchanged.The prefix strip was a 2021 workaround for Next.js dev mode not parsing PEM keys.
importKeyhas imported PEM strings directly sincesignJwtlanded, sojwtKeynow goes through that path too.Evidence
jwtKeyderives the wrong modulus, so every token fails withtoken-invalid-signature.After:
verify.test.ts"verifies a 3072-bit RS256 token with a 3072-bit PEM" passes.\nor\r\nescapes, a PEM wrapped in double or single quotes, a bare base64 body and a base64url body all verify.jwtKeystill fails withtoken-invalid-signature, so the dev-mode handshake hint is unchanged.Merge Danger
Door: two-way
Blast Radius: verification
jwtKeyalso verifies RS384 and RS512 tokens signed by the same key, without fetching the JWKS.verifyJwtfrom@clerk/backend/jwtreports a PEM key that cannot be imported astoken-invalid-signature, which is what ajwtKeyalready gave. Before, a bad PEM string passed toverifyJwtgavetoken-verification-failed.hasValidSignaturenow returnsfalsefor it instead of throwing.