Skip to content

Commit

Permalink
fix: redirect_uri 指定しないと invalid auth_token になる (#49)
Browse files Browse the repository at this point in the history
  • Loading branch information
a01sa01to authored Dec 16, 2024
1 parent 586ad80 commit eb114f3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
19 changes: 12 additions & 7 deletions webapp/api/oauth/_templates/authorize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ interface AuthorizeProps {
scopes: { name: string; description: string | null }[]
oauthFields: {
clientId: string
redirectUri: string
// client が指定してきた redirect_uri
redirectUri?: string
// client が指定してきた redirect_uri または DB に保存されている callback
redirectTo: string
state?: string
scope?: string
token: string
Expand Down Expand Up @@ -66,11 +69,13 @@ export const _Authorize = ({
</div>
<form method="POST" action="/oauth/callback" class="space-y-4">
<input type="hidden" name="client_id" value="${oauthFields.clientId}" />
<input
type="hidden"
name="redirect_uri"
value="${oauthFields.redirectUri}"
/>
${oauthFields.redirectUri
? html`<input
type="hidden"
name="redirect_uri"
value="${oauthFields.redirectUri}"
/>`
: ''}
${oauthFields.state
? html`<input
type="hidden"
Expand Down Expand Up @@ -106,7 +111,7 @@ export const _Authorize = ({
</form>
</div>
<p class="text-sm text-gray-600 text-center">
${new URL(oauthFields.redirectUri).origin} へリダイレクトします。
${new URL(oauthFields.redirectTo).origin} へリダイレクトします。
このアドレスが意図しているものか確認してください。
</p>
</div>
Expand Down
3 changes: 2 additions & 1 deletion webapp/api/oauth/authorize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,8 @@ app.get(
})),
oauthFields: {
clientId,
redirectUri: redirectTo,
redirectUri,
redirectTo,
state,
scope,
token,
Expand Down

0 comments on commit eb114f3

Please sign in to comment.