-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(adapter-nextjs): set cookie secure: false with non-SSL domain (#…
…13841) * feat(adapter-nextjs): allow cookie secure: false with non-SSL domain * fix(adapter-nextjs): wrong naming and impl. of isSSLOrigin * chore(adapter-nextjs): resolve comment
- Loading branch information
Showing
17 changed files
with
232 additions
and
7 deletions.
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
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
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
59 changes: 59 additions & 0 deletions
59
packages/adapter-nextjs/__tests__/auth/utils/isValidOrigin.test.ts
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,59 @@ | ||
import { isSSLOrigin, isValidOrigin } from '../../../src/auth/utils/origin'; | ||
|
||
describe('isValidOrigin', () => { | ||
test.each([ | ||
// Valid origins | ||
['http://example.com', true], | ||
['https://example.com', true], | ||
['http://www.example.com', true], | ||
['https://subdomain.example.com', true], | ||
['http://example.com:8080', true], | ||
['https://example.com:443', true], | ||
['http://localhost', true], | ||
['http://localhost:3000', true], | ||
['https://localhost:8080', true], | ||
['http://127.0.0.1', true], | ||
['http://127.0.0.1:8000', true], | ||
|
||
// Invalid origins | ||
['http://example.com/path', false], | ||
['https://example.com/path/to/resource', false], | ||
['http://example.com:8080/path', false], | ||
['ftp://example.com', false], | ||
['example.com', false], | ||
['http:/example.com', false], | ||
['https:example.com', false], | ||
['http://', false], | ||
['https://', false], | ||
['localhost', false], | ||
['http:localhost', false], | ||
['https://localhost:', false], | ||
['http://127.0.0.1:', false], | ||
['https://.com', false], | ||
['http://example.', false], | ||
['https://example.com:abc', false], | ||
['http:// example.com', false], | ||
['https://exam ple.com', false], | ||
['http://exa mple.com:8080', false], | ||
['https://example.com:8080:8081', false], | ||
['http://example.com:80:80', false], | ||
['https://.example.com', false], | ||
['http://example..com', false], | ||
['https://exam_ple.com', false], | ||
['https://example.com?query=param', false], | ||
['https://example.com:80/path#fragment', false], | ||
] as [string, boolean][])('validates origin %s as %s', (origin, expected) => { | ||
expect(isValidOrigin(origin)).toBe(expected); | ||
}); | ||
}); | ||
|
||
describe('isSSLOrigin', () => { | ||
test.each([ | ||
['https://some-app.com', true], | ||
['http://localhost', false], | ||
['http://localhost:3000', false], | ||
['https:// some-app.com', false], | ||
])('check origin SSL %s status as %s', (origin, expected) => { | ||
expect(isSSLOrigin(origin)).toBe(expected); | ||
}); | ||
}); |
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
Oops, something went wrong.