fix: ensure state is passed through for both github app types (#279)
parent
4aa5f67c1b
commit
cfaa80a9e7
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
'@hono/oauth-providers': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
ensure CSRF state returned to GitHub apps
|
|
@ -43,15 +43,15 @@ export class AuthFlow {
|
||||||
redirect() {
|
redirect() {
|
||||||
const url = 'https://github.com/login/oauth/authorize?'
|
const url = 'https://github.com/login/oauth/authorize?'
|
||||||
|
|
||||||
if (this.oauthApp) {
|
const queryParams = toQueryParams({
|
||||||
const parsedScope = toQueryParams({
|
client_id: this.client_id,
|
||||||
scope: this.scope,
|
|
||||||
state: this.state,
|
state: this.state,
|
||||||
|
// For GitHub apps, the scope is configured during the app setup / creation.
|
||||||
|
// For OAuth apps, we need to provide the scope.
|
||||||
|
...(this.oauthApp && { scope: this.scope }),
|
||||||
})
|
})
|
||||||
return `${url}${parsedScope}&client_id=${this.client_id}`
|
|
||||||
}
|
|
||||||
|
|
||||||
return `${url}client_id=${this.client_id}`
|
return url.concat(queryParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async getTokenFromCode() {
|
private async getTokenFromCode() {
|
||||||
|
|
Loading…
Reference in New Issue