Skip to content

Commit

Permalink
Do not issue refresh tokens to OIDC requests
Browse files Browse the repository at this point in the history
  • Loading branch information
motoki317 committed May 8, 2024
1 parent 396afc1 commit 0c5ec68
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions router/oauth2/token_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,11 @@ func (h *Handler) issueIDToken(client *model.OAuth2Client, token *model.OAuth2To
return jwt2.Sign(claims)
}

func (h *Handler) issueToken(client *model.OAuth2Client, userID uuid.UUID, scopes, originalScopes model.AccessScopes, allowRefreshToken bool) (*tokenResponse, error) {
token, err := h.Repo.IssueToken(client, userID, client.RedirectURI, scopes, h.AccessTokenExp, h.IsRefreshEnabled)
func (h *Handler) issueToken(client *model.OAuth2Client, userID uuid.UUID, scopes, originalScopes model.AccessScopes, grantTypeRefreshAllowed bool) (*tokenResponse, error) {
isOIDC := scopes.Contains("openid")
// OIDCの場合は、Refresh TokenのScopeの管理(主にoffline_access周り)が面倒なので、一律で発行しないことにする
refresh := h.IsRefreshEnabled && grantTypeRefreshAllowed && !isOIDC
token, err := h.Repo.IssueToken(client, userID, client.RedirectURI, scopes, h.AccessTokenExp, refresh)
if err != nil {
return nil, err
}
Expand All @@ -81,7 +84,7 @@ func (h *Handler) issueToken(client *model.OAuth2Client, userID uuid.UUID, scope
if len(originalScopes) != len(token.Scopes) {
res.Scope = token.Scopes.String()
}
if allowRefreshToken && token.IsRefreshEnabled() {
if token.IsRefreshEnabled() {
res.RefreshToken = token.RefreshToken
}
if scopes.Contains("openid") {
Expand Down

0 comments on commit 0c5ec68

Please sign in to comment.