Skip to content

fix(backend): throw on an invalid acceptsToken in authenticateRequest - #10856

Draft
wobsoriano wants to merge 2 commits into
mainfrom
rob/backend-validate-accepts-token
Draft

wobsoriano wants to merge 2 commits into
mainfrom
rob/backend-validate-accepts-token

Conversation

@wobsoriano

Copy link
Copy Markdown
Member

Description

authenticateRequest() didn't check acceptsToken, so an invalid value behaved differently depending on where the token was sent. With acceptsToken: 'sesion_token', a session cookie signed in, the same token in the Authorization header returned a signed-out state whose toAuth() threw, and an invalid entry inside an array was ignored.

authenticateRequest() now throws when acceptsToken is not 'any', a token type, or an array of token types. An empty array is still valid and rejects every token.

await clerkClient.authenticateRequest(request, { acceptsToken: 'sesion_token' });
// Error: Invalid acceptsToken: "sesion_token". Use 'any', one of 'session_token', 'api_key', 'm2m_token', 'oauth_token', or an array of them.

Checklist

  • pnpm test runs as expected.
  • pnpm build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

🤖 Generated with Claude under Rob's supervision.

@vercel

vercel Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
clerk-js-sandbox Ready Ready Preview Nov 17, 2026 5:58am UTC
swingset Ready Ready Preview Nov 17, 2026 5:58am UTC

Request Review

@changeset-bot

changeset-bot Bot commented Nov 17, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: f160051

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 11 packages
Name Type
@clerk/backend Minor
@clerk/astro Patch
@clerk/express Patch
@clerk/fastify Patch
@clerk/hono Patch
@clerk/nextjs Patch
@clerk/nuxt Patch
@clerk/react-router Patch
@clerk/tanstack-react-start Patch
@clerk/testing Patch
@clerk/swingset Patch

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

@coderabbitai

coderabbitai Bot commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@pkg-pr-new

pkg-pr-new Bot commented Nov 17, 2026

Copy link
Copy Markdown

Open in StackBlitz

@clerk/astro

npm i https://pkg.pr.new/@clerk/astro@10856

@clerk/backend

npm i https://pkg.pr.new/@clerk/backend@10856

@clerk/chrome-extension

npm i https://pkg.pr.new/@clerk/chrome-extension@10856

@clerk/clerk-js

npm i https://pkg.pr.new/@clerk/clerk-js@10856

@clerk/electron

npm i https://pkg.pr.new/@clerk/electron@10856

@clerk/electron-passkeys

npm i https://pkg.pr.new/@clerk/electron-passkeys@10856

@clerk/eslint-plugin

npm i https://pkg.pr.new/@clerk/eslint-plugin@10856

@clerk/expo

npm i https://pkg.pr.new/@clerk/expo@10856

@clerk/expo-biometrics

npm i https://pkg.pr.new/@clerk/expo-biometrics@10856

@clerk/expo-google-signin

npm i https://pkg.pr.new/@clerk/expo-google-signin@10856

@clerk/expo-native-components

npm i https://pkg.pr.new/@clerk/expo-native-components@10856

@clerk/expo-passkeys

npm i https://pkg.pr.new/@clerk/expo-passkeys@10856

@clerk/express

npm i https://pkg.pr.new/@clerk/express@10856

@clerk/fastify

npm i https://pkg.pr.new/@clerk/fastify@10856

@clerk/hono

npm i https://pkg.pr.new/@clerk/hono@10856

@clerk/localizations

npm i https://pkg.pr.new/@clerk/localizations@10856

@clerk/mosaic

npm i https://pkg.pr.new/@clerk/mosaic@10856

@clerk/nextjs

npm i https://pkg.pr.new/@clerk/nextjs@10856

@clerk/nuxt

npm i https://pkg.pr.new/@clerk/nuxt@10856

@clerk/react

npm i https://pkg.pr.new/@clerk/react@10856

@clerk/react-router

npm i https://pkg.pr.new/@clerk/react-router@10856

@clerk/shared

npm i https://pkg.pr.new/@clerk/shared@10856

@clerk/tanstack-react-start

npm i https://pkg.pr.new/@clerk/tanstack-react-start@10856

@clerk/testing

npm i https://pkg.pr.new/@clerk/testing@10856

@clerk/ui

npm i https://pkg.pr.new/@clerk/ui@10856

@clerk/upgrade

npm i https://pkg.pr.new/@clerk/upgrade@10856

@clerk/vue

npm i https://pkg.pr.new/@clerk/vue@10856

commit: f160051

This branch was successfully deployed

2 active deployments
Preview – swingset — f160051d Deployed Nov 17, 2026 by vercel[bot]
Preview – clerk-js-sandbox — f160051d Deployed Nov 17, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant