Skip to content

Commit

Permalink
Merge pull request #2382 from smarterclayton/scope_check
Browse files Browse the repository at this point in the history
If the request already has the scope, don't fetchToken again
  • Loading branch information
dmcgowan committed Aug 24, 2017
2 parents 5f6282d + 23f8ca8 commit d9e0121
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions registry/client/auth/session.go
Expand Up @@ -279,6 +279,9 @@ func (th *tokenHandler) getToken(params map[string]string, additionalScopes ...s
}
var addedScopes bool
for _, scope := range additionalScopes {
if hasScope(scopes, scope) {
continue
}
scopes = append(scopes, scope)
addedScopes = true
}
Expand All @@ -302,6 +305,15 @@ func (th *tokenHandler) getToken(params map[string]string, additionalScopes ...s
return th.tokenCache, nil
}

func hasScope(scopes []string, scope string) bool {
for _, s := range scopes {
if s == scope {
return true
}
}
return false
}

type postTokenResponse struct {
AccessToken string `json:"access_token"`
RefreshToken string `json:"refresh_token"`
Expand Down

0 comments on commit d9e0121

Please sign in to comment.