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() {
|
||||
const url = 'https://github.com/login/oauth/authorize?'
|
||||
|
||||
if (this.oauthApp) {
|
||||
const parsedScope = toQueryParams({
|
||||
scope: this.scope,
|
||||
state: this.state,
|
||||
})
|
||||
return `${url}${parsedScope}&client_id=${this.client_id}`
|
||||
}
|
||||
const queryParams = toQueryParams({
|
||||
client_id: this.client_id,
|
||||
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}client_id=${this.client_id}`
|
||||
return url.concat(queryParams);
|
||||
}
|
||||
|
||||
private async getTokenFromCode() {
|
||||
|
|
Loading…
Reference in New Issue