Merge pull request #2171 from ruediger-maass/resolver401
Adds handling of 401 for POST /v2/token without authentication
This commit is contained in:
commit
e6a3dd3550
@ -498,7 +498,8 @@ func (r *dockerBase) fetchTokenWithOAuth(ctx context.Context, to tokenOptions) (
|
|||||||
|
|
||||||
// Registries without support for POST may return 404 for POST /v2/token.
|
// Registries without support for POST may return 404 for POST /v2/token.
|
||||||
// As of September 2017, GCR is known to return 404.
|
// As of September 2017, GCR is known to return 404.
|
||||||
if (resp.StatusCode == 405 && r.username != "") || resp.StatusCode == 404 {
|
// As of February 2018, JFrog Artifactory is known to return 401.
|
||||||
|
if (resp.StatusCode == 405 && r.username != "") || resp.StatusCode == 404 || resp.StatusCode == 401 {
|
||||||
return r.getToken(ctx, to)
|
return r.getToken(ctx, to)
|
||||||
} else if resp.StatusCode < 200 || resp.StatusCode >= 400 {
|
} else if resp.StatusCode < 200 || resp.StatusCode >= 400 {
|
||||||
b, _ := ioutil.ReadAll(io.LimitReader(resp.Body, 64000)) // 64KB
|
b, _ := ioutil.ReadAll(io.LimitReader(resp.Body, 64000)) // 64KB
|
||||||
|
Loading…
Reference in New Issue
Block a user