@@ -83,17 +83,21 @@ func GrantAdditionalScopes(grantScopes string) auth.AccessTokenScope {
83
83
84
84
var accessScopes []string // the scopes for access control, but not for general information
85
85
for _ , scope := range strings .Split (grantScopes , " " ) {
86
- if ! slices .Contains (generalScopesSupported , scope ) {
86
+ if scope != "" && ! slices .Contains (generalScopesSupported , scope ) {
87
87
accessScopes = append (accessScopes , scope )
88
88
}
89
89
}
90
90
91
91
// since version 1.22, access tokens grant full access to the API
92
92
// with this access is reduced only if additional scopes are provided
93
- // TODO: if there are invalid access scopes, then it is treated as "all", but would we really always treat invalid scopes as "all"?
94
- accessTokenScope := auth .AccessTokenScope (strings .Join (accessScopes , "," ))
95
- if normalizedAccessTokenScope , err := accessTokenScope .Normalize (); err == nil && normalizedAccessTokenScope != "" {
96
- return normalizedAccessTokenScope
93
+ if len (accessScopes ) > 0 {
94
+ accessTokenScope := auth .AccessTokenScope (strings .Join (accessScopes , "," ))
95
+ if normalizedAccessTokenScope , err := accessTokenScope .Normalize (); err == nil {
96
+ return normalizedAccessTokenScope
97
+ }
98
+ // TODO: if there are invalid access scopes (err != nil),
99
+ // then it is treated as "all", maybe in the future we should make it stricter to return an error
100
+ // at the moment, to avoid breaking 1.22 behavior, invalid tokens are also treated as "all"
97
101
}
98
102
// fallback, empty access scope is treated as "all" access
99
103
return auth .AccessTokenScopeAll
0 commit comments