Skip to content

Commit cd44199

Browse files
authored
Make bearer authentication matching case insensitve (GoogleContainerTools#561)
1 parent f600c13 commit cd44199

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

‎jib-core/src/main/java/com/google/cloud/tools/jib/registry/RegistryAuthenticator.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ static RegistryAuthenticator fromAuthenticationMethod(
6161
return null;
6262
}
6363

64-
// Checks that the authentication method starts with 'Bearer '.
65-
if (!authenticationMethod.matches("^Bearer .*")) {
64+
// Checks that the authentication method starts with 'bearer ' (case insensitive).
65+
if (!authenticationMethod.matches("^(?i)(bearer) .*")) {
6666
throw newRegistryAuthenticationFailedException(authenticationMethod, "Bearer");
6767
}
6868

‎jib-core/src/test/java/com/google/cloud/tools/jib/registry/RegistryAuthenticatorTest.java‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@ public void testFromAuthenticationMethod_bearer()
3434
Assert.assertEquals(
3535
new URL("https://somerealm?service=someservice&scope=repository:someimage:scope"),
3636
registryAuthenticator.getAuthenticationUrl("scope"));
37+
38+
registryAuthenticator =
39+
RegistryAuthenticator.fromAuthenticationMethod(
40+
"bEaReR realm=\"https://somerealm\",service=\"someservice\",scope=\"somescope\"",
41+
"someimage");
42+
Assert.assertEquals(
43+
new URL("https://somerealm?service=someservice&scope=repository:someimage:scope"),
44+
registryAuthenticator.getAuthenticationUrl("scope"));
3745
}
3846

3947
@Test

0 commit comments

Comments
 (0)