mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
registry: fix auth bug
Signed-off-by: Tibor Vass <tibor@docker.com>
This commit is contained in:
parent
7fffcfff32
commit
fc29f7f70b
1 changed files with 2 additions and 5 deletions
|
@ -80,13 +80,10 @@ func (tr *authTransport) RoundTrip(orig *http.Request) (*http.Response, error) {
|
|||
return tr.RoundTripper.RoundTrip(req)
|
||||
}
|
||||
|
||||
var askedForToken bool
|
||||
|
||||
// Don't override
|
||||
if req.Header.Get("Authorization") == "" {
|
||||
if req.Header.Get("X-Docker-Token") == "true" {
|
||||
if req.Header.Get("X-Docker-Token") == "true" && len(tr.Username) > 0 {
|
||||
req.SetBasicAuth(tr.Username, tr.Password)
|
||||
askedForToken = true
|
||||
} else if len(tr.token) > 0 {
|
||||
req.Header.Set("Authorization", "Token "+strings.Join(tr.token, ","))
|
||||
}
|
||||
|
@ -96,7 +93,7 @@ func (tr *authTransport) RoundTrip(orig *http.Request) (*http.Response, error) {
|
|||
delete(tr.modReq, orig)
|
||||
return nil, err
|
||||
}
|
||||
if askedForToken && len(resp.Header["X-Docker-Token"]) > 0 {
|
||||
if len(resp.Header["X-Docker-Token"]) > 0 {
|
||||
tr.token = resp.Header["X-Docker-Token"]
|
||||
}
|
||||
resp.Body = &transport.OnEOFReader{
|
||||
|
|
Loading…
Reference in a new issue