@@ -37,7 +37,7 @@ const scopeRegex = /scope="([^"]+)"/;
3737
3838// https://docs.docker.com/registry/spec/auth/token/#how-to-authenticate
3939export async function requestEnsureAuthenticated ( params : CommonParams , httpOptions : { type : string ; url : string ; headers : HEADERS ; data ?: Buffer } , ociRef : OCIRef | OCICollectionRef ) {
40- // If needed, Initialize the Authorization header cache.
40+ // If needed, Initialize the Authorization header cache.
4141 if ( ! params . cachedAuthHeader ) {
4242 params . cachedAuthHeader = { } ;
4343 }
@@ -54,14 +54,14 @@ export async function requestEnsureAuthenticated(params: CommonParams, httpOptio
5454
5555 const initialAttemptRes = await requestResolveHeaders ( httpOptions , output ) ;
5656
57- // For anything except a 401 response
58- // Simply return the original response to the caller.
59- if ( initialAttemptRes . statusCode !== 401 ) {
57+ // For anything except a 401 (invalid/no token) or 403 (insufficient scope)
58+ // response simply return the original response to the caller.
59+ if ( initialAttemptRes . statusCode !== 401 && initialAttemptRes . statusCode !== 403 ) {
6060 output . write ( `[httpOci] ${ initialAttemptRes . statusCode } (${ maybeCachedAuthHeader ? 'Cached' : 'NoAuth' } ): ${ httpOptions . url } ` , LogLevel . Trace ) ;
6161 return initialAttemptRes ;
6262 }
6363
64- // -- 'responseAttempt' status code was 401 at this point.
64+ // -- 'responseAttempt' status code was 401 or 403 at this point.
6565
6666 // Attempt to authenticate via WWW-Authenticate Header.
6767 const wwwAuthenticate = initialAttemptRes . resHeaders [ 'WWW-Authenticate' ] || initialAttemptRes . resHeaders [ 'www-authenticate' ] ;
0 commit comments