Skip to content

Commit 2e0a447

Browse files
committed
fix(security): encode redirect_uri, limit state payload, fix iframe timeout in authorizer-js
1 parent 1213d6f commit 2e0a447

2 files changed

Lines changed: 8 additions & 7 deletions

File tree

src/index.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@ export class Authorizer {
116116
if (err.error) {
117117
window.location.replace(
118118
`${this.config.authorizerURL}/app?state=${encode(
119-
JSON.stringify(this.config),
120-
)}&redirect_uri=${this.config.redirectURL}`,
119+
JSON.stringify({ clientID: this.config.clientID, redirectURL: this.config.redirectURL, authorizerURL: this.config.authorizerURL }),
120+
)}&redirect_uri=${encodeURIComponent(this.config.redirectURL || '')}`,
121121
);
122122
}
123123

@@ -142,8 +142,8 @@ export class Authorizer {
142142

143143
window.location.replace(
144144
`${this.config.authorizerURL}/app?state=${encode(
145-
JSON.stringify(this.config),
146-
)}&redirect_uri=${this.config.redirectURL}`,
145+
JSON.stringify({ clientID: this.config.clientID, redirectURL: this.config.redirectURL, authorizerURL: this.config.authorizerURL }),
146+
)}&redirect_uri=${encodeURIComponent(this.config.redirectURL || '')}`,
147147
);
148148
return this.errorResponse(err);
149149
}
@@ -350,9 +350,9 @@ export class Authorizer {
350350
if (roles && roles.length) urlState += `&roles=${roles.join(',')}`;
351351

352352
window.location.replace(
353-
`${this.config.authorizerURL}/oauth_login/${oauthProvider}?redirect_uri=${
354-
redirect_uri || this.config.redirectURL
355-
}&state=${urlState}`,
353+
`${this.config.authorizerURL}/oauth_login/${oauthProvider}?redirect_uri=${encodeURIComponent(
354+
redirect_uri || this.config.redirectURL || ''
355+
)}&state=${encodeURIComponent(urlState)}`,
356356
);
357357
};
358358

src/utils.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ export const executeIframe = (
124124
};
125125

126126
const timeoutSetTimeoutId = setTimeout(() => {
127+
reject(new Error('Authorization timeout'));
127128
removeIframe();
128129
}, timeoutInSeconds * 1000);
129130

0 commit comments

Comments
 (0)