Skip to content

Commit

Permalink
Fixes RegistryAuthenticator to handle case insensitive Basic method (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
conblem authored and coollog committed Jul 11, 2018
1 parent 23777be commit ac29205
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,9 @@ public class RegistryAuthenticator {
@Nullable
static RegistryAuthenticator fromAuthenticationMethod(
String authenticationMethod, String repository) throws RegistryAuthenticationFailedException {
// If the authentication method starts with 'Basic ', no registry authentication is needed.
if (authenticationMethod.matches("^Basic .*")) {
// If the authentication method starts with 'basic ' (case insensitive), no registry
// authentication is needed.
if (authenticationMethod.matches("^(?i)(basic) .*")) {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,16 @@ public void testFromAuthenticationMethod_basic() throws RegistryAuthenticationFa
RegistryAuthenticator.fromAuthenticationMethod(
"Basic realm=\"https://somerealm\",service=\"someservice\",scope=\"somescope\"",
"someimage"));

Assert.assertNull(
RegistryAuthenticator.fromAuthenticationMethod(
"BASIC realm=\"https://somerealm\",service=\"someservice\",scope=\"somescope\"",
"someimage"));

Assert.assertNull(
RegistryAuthenticator.fromAuthenticationMethod(
"bASIC realm=\"https://somerealm\",service=\"someservice\",scope=\"somescope\"",
"someimage"));
}

@Test
Expand Down

0 comments on commit ac29205

Please sign in to comment.