Skip to content

Commit

Permalink
fix: ensure state is passed through for both github app types (#279)
Browse files Browse the repository at this point in the history
  • Loading branch information
rawkode authored Nov 28, 2023
1 parent 4aa5f67 commit cfaa80a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .changeset/hip-owls-give.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@hono/oauth-providers': patch
---

ensure CSRF state returned to GitHub apps
16 changes: 8 additions & 8 deletions packages/oauth-providers/src/providers/github/authFlow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit cfaa80a

Please sign in to comment.