OCI: WWW-Authenticate's scheme should be treated case-insensitive (#336)

This commit is contained in:
Nikolay Edigaryev
2022-11-25 16:59:38 +04:00
committed by GitHub
parent 70f9fcc12e
commit c27d4a089c
+2 -2
View File
@@ -312,7 +312,7 @@ class Registry {
let wwwAuthenticate = try WWWAuthenticate(rawHeaderValue: wwwAuthenticateRaw) let wwwAuthenticate = try WWWAuthenticate(rawHeaderValue: wwwAuthenticateRaw)
if wwwAuthenticate.scheme == "Basic" { if wwwAuthenticate.scheme.lowercased() == "basic" {
if let (user, password) = try lookupCredentials(host: baseURL.host!) { if let (user, password) = try lookupCredentials(host: baseURL.host!) {
currentAuthToken = BasicAuthentication(user: user, password: password) currentAuthToken = BasicAuthentication(user: user, password: password)
} }
@@ -320,7 +320,7 @@ class Registry {
return return
} }
if wwwAuthenticate.scheme != "Bearer" { if wwwAuthenticate.scheme.lowercased() != "bearer" {
throw RegistryError.AuthFailed(why: "WWW-Authenticate header's authentication scheme " throw RegistryError.AuthFailed(why: "WWW-Authenticate header's authentication scheme "
+ "\"\(wwwAuthenticate.scheme)\" is unsupported, expected \"Bearer\" scheme") + "\"\(wwwAuthenticate.scheme)\" is unsupported, expected \"Bearer\" scheme")
} }