Skip to content

Commit

Permalink
Merge pull request #884 from EyeDevelop/eyedevelop/add-leniency-for-r…
Browse files Browse the repository at this point in the history
…egistries

Add more leniency towards registries that malform WWW-Authenticate.
  • Loading branch information
samruddhikhandale committed Sep 3, 2024
2 parents cf9f0ea + 9ac6701 commit 11587da
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/spec-configuration/httpOCIRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,10 @@ export async function requestEnsureAuthenticated(params: CommonParams, httpOptio
return;
}

switch (wwwAuthenticate.split(' ')[0]) {
const authenticationMethod = wwwAuthenticate.split(' ')[0];
switch (authenticationMethod.toLowerCase()) {
// Basic realm="localhost"
case 'Basic':
case 'basic':

output.write(`[httpOci] Attempting to authenticate via 'Basic' auth.`, LogLevel.Trace);

Expand All @@ -87,7 +88,7 @@ export async function requestEnsureAuthenticated(params: CommonParams, httpOptio
break;

// Bearer realm="https://auth.docker.io/token",service="registry.docker.io",scope="repository:samalba/my-app:pull,push"
case 'Bearer':
case 'bearer':

output.write(`[httpOci] Attempting to authenticate via 'Bearer' auth.`, LogLevel.Trace);

Expand Down Expand Up @@ -116,7 +117,7 @@ export async function requestEnsureAuthenticated(params: CommonParams, httpOptio
break;

default:
output.write(`[httpOci] ERR: Unsupported authentication mode '${wwwAuthenticate.split(' ')[0]}'`, LogLevel.Error);
output.write(`[httpOci] ERR: Unsupported authentication mode '${authenticationMethod}'`, LogLevel.Error);
return;
}

Expand Down

0 comments on commit 11587da

Please sign in to comment.