Skip to content

Commit

Permalink
Remove validation of auth scopes in OciRegistryApi to support GitHub …
Browse files Browse the repository at this point in the history
…package registry
  • Loading branch information
SgtSilvio committed Jul 23, 2024
1 parent 6b5095b commit 4cfbf74
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -557,11 +557,11 @@ internal class OciRegistryApi(httpClient: HttpClient) {
val service = bearerParams["service"] ?: throw IllegalArgumentException("bearer authorization header is missing 'service'")
val scope = bearerParams["scope"] ?: throw IllegalArgumentException("bearer authorization header is missing 'scope'")
val scopesFromResponse = scope.split(' ').mapTo(HashSet()) { it.decodeToResourceScope() }
if (scopesFromResponse != scopes) {
throw IllegalStateException("scopes do not match, required: $scopes, from bearer authorization header: $scopesFromResponse")
}
// if (scopesFromResponse != scopes) { // TODO GitHub container registry always returns pull as action (no pull,push) and returns "user/image" as repository when sending basic auth in first request, log a warning instead?
// throw IllegalStateException("scopes do not match, required: $scopes, from bearer authorization header: $scopesFromResponse")
// }
return tokenCache.getMono(TokenCacheKey(registryUrl, scopes, credentials?.hashed())) { key ->
val scopeParams = key.scopes.joinToString("&scope=", "scope=") { it.encodeToString() }
val scopeParams = scopesFromResponse.joinToString("&scope=", "scope=") { it.encodeToString() }
httpClient.headers { headers ->
if (credentials != null) {
headers[HttpHeaderNames.AUTHORIZATION] = credentials.encodeBasicAuthorization()
Expand Down

0 comments on commit 4cfbf74

Please sign in to comment.