chore(backend): Reject OAuth JWTs for session token token type#7765
chore(backend): Reject OAuth JWTs for session token token type#7765wobsoriano merged 6 commits intomainfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: 766bc68 The changes in this PR will be included in the next version bump. This PR includes changesets to release 10 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 |
|
|
||
| await app.setup(); | ||
| await app.withEnv(appConfigs.envs.withEmailCodes); | ||
| await app.withEnv(appConfigs.envs.withAPIKeys); |
There was a problem hiding this comment.
We use the withAPIKeys env for machine auth related tests.
OAuth applications use JWT access tokens here.
📝 WalkthroughWalkthroughThis pull request improves token type validation in the authentication system. A new check is added to reject OAuth JWTs when they appear in the Authorization header but a session token is expected. The implementation includes adding an 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
| if (isOAuthJwt(tokenInHeader!)) { | ||
| return signedOut({ | ||
| tokenType: TokenType.SessionToken, | ||
| authenticateContext, | ||
| reason: AuthErrorReason.TokenTypeMismatch, | ||
| message: '', | ||
| }); | ||
| } |
There was a problem hiding this comment.
isOAuthJwt uses verifyToken under the hood, but also checks if it is a valid OAuth JWT access token based on rfc9068
@clerk/agent-toolkit
@clerk/astro
@clerk/backend
@clerk/chrome-extension
@clerk/clerk-js
@clerk/dev-cli
@clerk/expo
@clerk/expo-passkeys
@clerk/express
@clerk/fastify
@clerk/localizations
@clerk/nextjs
@clerk/nuxt
@clerk/react
@clerk/react-router
@clerk/shared
@clerk/tanstack-react-start
@clerk/testing
@clerk/ui
@clerk/upgrade
@clerk/vue
commit: |
Description
Improves token type validation by ensuring OAuth JWTs are properly rejected when
acceptsTokenis set to'session_token'(default).Checklist
pnpm testruns as expected.pnpm buildruns as expected.Type of change
Summary by CodeRabbit
Release Notes
Bug Fixes
Tests