Skip to content

Commit 7691832

Browse files
committed
fix
1 parent c363bd0 commit 7691832

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

routers/api/v1/api.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ func tokenRequiresScopes(requiredScopeCategories ...auth_model.AccessTokenScopeC
321321
}
322322

323323
if !allow {
324-
ctx.Error(http.StatusForbidden, "tokenRequiresScope", fmt.Sprintf("token does not have at least one of required scope(s): %v", requiredScopes))
324+
ctx.Error(http.StatusForbidden, "tokenRequiresScope", fmt.Sprintf("token does not have at least one of required scope(s), required=%v, token scope=%v", requiredScopes, scope))
325325
return
326326
}
327327

services/oauth2_provider/access_token.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ func GrantAdditionalScopes(grantScopes string) auth.AccessTokenScope {
9191
// since version 1.22, access tokens grant full access to the API
9292
// with this access is reduced only if additional scopes are provided
9393
accessTokenScope := auth.AccessTokenScope(strings.Join(tokenScopes, ","))
94-
if accessTokenWithAdditionalScopes, err := accessTokenScope.Normalize(); err == nil && len(tokenScopes) > 0 {
94+
if accessTokenWithAdditionalScopes, err := accessTokenScope.Normalize(); err == nil && accessTokenWithAdditionalScopes != "" {
9595
return accessTokenWithAdditionalScopes
9696
}
9797
return auth.AccessTokenScopeAll

services/oauth2_provider/additional_scopes_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ func TestGrantAdditionalScopes(t *testing.T) {
1414
grantScopes string
1515
expectedScopes string
1616
}{
17+
{"", "all"},
1718
{"openid profile email", "all"},
1819
{"openid profile email groups", "all"},
1920
{"openid profile email all", "all"},
@@ -27,7 +28,7 @@ func TestGrantAdditionalScopes(t *testing.T) {
2728
}
2829

2930
for _, test := range tests {
30-
t.Run(test.grantScopes, func(t *testing.T) {
31+
t.Run("scope:"+test.grantScopes, func(t *testing.T) {
3132
result := GrantAdditionalScopes(test.grantScopes)
3233
assert.Equal(t, test.expectedScopes, string(result))
3334
})

0 commit comments

Comments
 (0)