-
Notifications
You must be signed in to change notification settings - Fork 254
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
feat(backend): Limit handshake to document requests #2352
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
99c6620
feat(backend): Support dev handshake where the redirect ends up tainted
BRKalow b103ec7
feat(backend): Fix tests, only check sec-fetch-dest for handshake elg…
BRKalow 412c5f5
chore(repo): Add changeset
BRKalow 841b0eb
fix(backend): Update request unit tests
BRKalow 0759578
fix(fastify): Update snapshot tests
BRKalow df9aba8
Merge branch 'main' into brk.feat/handshake-fetch
BRKalow 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 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/backend': patch | ||
--- | ||
|
||
Update the handshake flow to only trigger for document requests. |
This file contains 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 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 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 |
---|---|---|
|
@@ -123,6 +123,7 @@ export default (QUnit: QUnit) => { | |
const defaultHeaders: Record<string, string> = { | ||
host: 'example.com', | ||
'user-agent': 'Mozilla/TestAgent', | ||
'sec-fetch-dest': 'document', | ||
}; | ||
|
||
const mockRequest = (headers = {}, requestUrl = 'http://clerk.com/path') => { | ||
|
@@ -268,9 +269,7 @@ export default (QUnit: QUnit) => { | |
test('cookieToken: returns handshake when clientUat is missing or equals to 0 and is satellite and not is synced [11y]', async assert => { | ||
const requestState = await authenticateRequest( | ||
mockRequestWithCookies( | ||
{ | ||
'Sec-Fetch-Dest': 'document', | ||
}, | ||
{}, | ||
{ | ||
__client_uat: '0', | ||
}, | ||
|
@@ -299,6 +298,7 @@ export default (QUnit: QUnit) => { | |
mockRequestWithCookies( | ||
{ | ||
...defaultHeaders, | ||
'sec-fetch-dest': 'empty', | ||
'user-agent': '[some-agent]', | ||
}, | ||
{ __client_uat: '0' }, | ||
|
@@ -388,12 +388,13 @@ export default (QUnit: QUnit) => { | |
assert.strictEqual(requestState.toAuth(), null); | ||
}); | ||
|
||
test('cookieToken: returns undefined when crossOriginReferrer in development and is satellite [6n]', async assert => { | ||
test('cookieToken: returns signedIn when satellite but valid token and clientUat', async assert => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test name was inaccurate 🧐 |
||
// Scenario: after auth action on Clerk-hosted UIs | ||
const requestState = await authenticateRequest( | ||
mockRequestWithCookies( | ||
{ | ||
...defaultHeaders, | ||
'sec-fetch-dest': 'empty', | ||
// this is not a typo, it's intentional to be `referer` to match HTTP header key | ||
referer: 'https://clerk.com', | ||
}, | ||
|
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.
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.
Now that we're defaulting to
sec-fetch-dest: document
, we need to explicitly set it to empty for this test case