Skip to content

Commit

Permalink
Improve insufficient scopes handling in OciRegistryApi
Browse files Browse the repository at this point in the history
  • Loading branch information
SgtSilvio committed Jul 22, 2024
1 parent 1412fce commit 7253069
Showing 1 changed file with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -577,15 +577,16 @@ internal class OciRegistryApi(httpClient: HttpClient) {
}
val registryToken = OciRegistryToken(token)
val grantedScopes = registryToken.claims?.scopes
if ((grantedScopes == null) || (grantedScopes == key.scopes)) {
registryToken
} else {
tokenCache.asMap().putIfAbsent(
key.copy(scopes = grantedScopes),
CompletableFuture.completedFuture(registryToken),
)
if ((grantedScopes != null) && (grantedScopes != key.scopes)) {
if (grantedScopes.isNotEmpty()) {
tokenCache.asMap().putIfAbsent(
key.copy(scopes = grantedScopes),
CompletableFuture.completedFuture(registryToken),
)
}
throw InsufficientScopesException(key.scopes, grantedScopes)
}
registryToken
}
}.map { encodeBearerAuthorization(it.token) }
}
Expand Down

0 comments on commit 7253069

Please sign in to comment.