Skip to content

Commit fd628bb

Browse files
committed
Reject callback URLs with a different protocol
1 parent e1d8fa4 commit fd628bb

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

src/routes/authorize.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ export const validateRedirect = (
8888
const callback = new URL(callbackUrl);
8989
return (
9090
redirect.host === callback.host
91+
&& redirect.protocol == callback.protocol
9192
&& redirect.port === callback.port
9293
&& redirect.pathname.startsWith(callback.pathname)
9394
);

tests/authorize.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ describe("validateRedirect function", () => {
2323
"http://example.com:8080/path",
2424
"http://oauth.example.com:8080/path",
2525
"http://example.org",
26+
"https://example.com/path",
2627
].forEach((invalidRedirect) => {
2728
it(`should reject ${invalidRedirect}`, () => {
2829
expect(validateRedirect(invalidRedirect, callback)).toBe(false);

0 commit comments

Comments
 (0)