feat(express,fastify,tanstack-react-start,react-router): Support machine auth tokens in getAuth()#6067
Conversation
🦋 Changeset detectedLatest commit: 4c9d741 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 |
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
|
!snapshot |
|
Hey @wobsoriano - the snapshot version command generated the following package versions:
Tip: Use the snippet copy button below to quickly install the required packages. |
getAuth()
getAuth()getAuth()
@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: |
| const req = mockRequestWithAuth({ userId: 'user_12345' }); | ||
| expect(getAuth(req)).toHaveProperty('userId', 'user_12345'); | ||
| }); | ||
|
|
There was a problem hiding this comment.
Do we wanna add a test case that asserts that the default acceptsToken is 'any'?
There was a problem hiding this comment.
So the actual authenticateRequest() call is using 'any' and cannot be overridden. Meaning any session or machine request will be verified.
However, the acceptsToken in getAuth() (which defaults to session_token) is used after authentication to filter or coerce the returned auth object to match the expected type.
There was a problem hiding this comment.
Ah, sorry, I misread lol. The changeset is saying what you're saying. So never mind :)
Description
This PR is a continuation of the main Machine Authentication PR but focuses on adding the type of token option to
getAuth()helper across SDKs. This is still backwards compat, and set tosession_tokenby default.Before:
After:
Checklist
pnpm testruns as expected.pnpm buildruns as expected.Type of change