Skip to content

Commit

Permalink
clarify why not error for onlyPublicGroups
Browse files Browse the repository at this point in the history
- in the review it came out the part was not clear without the comment
  • Loading branch information
marcellmars committed Nov 20, 2024
1 parent 08dfb22 commit f26c7b7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions routers/web/auth/oauth2_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ func InfoOAuth(ctx *context.Context) {
accessTokenScope, _ = auth_service.GetOAuthAccessTokenScopeAndUserID(ctx, auths[1])
}
}

// since version 1.22 does not verify if groups should be public-only,
// onlyPublicGroups will be set only if 'public-only' is included in a valid scope
onlyPublicGroups, _ := accessTokenScope.PublicOnly()
groups, err := oauth2_provider.GetOAuthGroupsForUser(ctx, ctx.Doer, onlyPublicGroups)
if err != nil {
Expand Down
3 changes: 3 additions & 0 deletions services/oauth2_provider/access_token.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,9 @@ func NewAccessTokenResponse(ctx context.Context, grant *auth.OAuth2Grant, server
}
if grant.ScopeContains("groups") {
accessTokenScope := GrantAdditionalScopes(grant.Scope)

// since version 1.22 does not verify if groups should be public-only,
// onlyPublicGroups will be set only if 'public-only' is included in a valid scope
onlyPublicGroups, _ := accessTokenScope.PublicOnly()

groups, err := GetOAuthGroupsForUser(ctx, user, onlyPublicGroups)
Expand Down

0 comments on commit f26c7b7

Please sign in to comment.