-
Notifications
You must be signed in to change notification settings - Fork 353
feat(express,fastify,tanstack-react-start,react-router): Support machine auth tokens in getAuth()
#6067
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally LGTM
}); | ||
|
||
it('returns auth from request', async () => { | ||
const req = mockRequestWithAuth({ userId: 'user_12345' }); | ||
expect(getAuth(req)).toHaveProperty('userId', 'user_12345'); | ||
}); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we wanna add a test case that asserts that the default acceptsToken
is 'any'
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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_token
by default.Before:
After:
Checklist
pnpm test
runs as expected.pnpm build
runs as expected.Type of change