-
Notifications
You must be signed in to change notification settings - Fork 370
chore(nextjs): Improve machine auth verification calls #6367
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
73bf0e4
chore: Add verified machine auth object to request data header
wobsoriano 321711b
chore: use existing header
wobsoriano 57a6875
chore: Reconstruct machine auth object
wobsoriano ee53247
chore: clean up
wobsoriano 176182b
chore: update tests
wobsoriano 56a7c86
chore: fix types in tests
wobsoriano bbdc5ca
chore: fix types in tests
wobsoriano 83e00ed
chore: remove duplications
wobsoriano 0c7e51f
chore: add changeset
wobsoriano cc4358b
chore: fix imports
wobsoriano File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@clerk/nextjs": patch | ||
--- | ||
|
||
Improved machine auth verification within API routes |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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.
💡 Verification agent
🧩 Analysis chain
Conditional redirect methods based on token type - approve with security review needed.
This change correctly restricts redirect methods to session tokens only, which makes semantic sense since machine tokens, API keys, and OAuth tokens are for programmatic access and don't need user redirect capabilities.
However, this modifies core authentication logic and should be reviewed by the security team.
Please tag
clerk/security
for review of this authentication logic change.Also, ensure test coverage exists for both branches of this conditional logic:
If test coverage is missing, please add tests to verify:
🏁 Script executed:
Length of output: 76688
Conditional redirect methods for session tokens – approve with security review and add missing tests
The change correctly restricts
redirectToSignIn
/redirectToSignUp
toSessionToken
cases, aligning behavior with token semantics.However, no unit tests currently cover this branch in
packages/nextjs/src/app-router/server/auth.ts
.• Tag
clerk/security
for review of the updated authentication logic.• Add a new test suite under
packages/nextjs/src/app-router/server/__tests__/auth.test.ts
covering:authObject.tokenType === TokenType.SessionToken
, the returned object includes workingredirectToSignIn
andredirectToSignUp
methods.authObject.tokenType !== TokenType.SessionToken
, the returned object does not expose redirect methods (calls should error or be undefined).🤖 Prompt for AI Agents
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.
@wobsoriano Do types already cover this case ?
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.
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.
@panteliselef yes, but want to make sure machine auth objects dont include redirect functions at runtime as well