Skip to content

Commit

Permalink
Merge pull request #5761 from thaJeztah/1.4_backport_fix_auth_ua
Browse files Browse the repository at this point in the history
[release/1.4] Fix incorrect UA used for registry authentication
  • Loading branch information
dmcgowan committed Jul 20, 2021
2 parents a368d28 + 67a0576 commit e4418db
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions remotes/docker/authorizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (

"github.com/containerd/containerd/errdefs"
"github.com/containerd/containerd/log"
"github.com/containerd/containerd/version"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"golang.org/x/net/context/ctxhttp"
Expand Down Expand Up @@ -356,6 +357,9 @@ func (ah *authHandler) fetchTokenWithOAuth(ctx context.Context, to tokenOptions)
req.Header[k] = append(req.Header[k], v...)
}
}
if len(req.Header.Get("User-Agent")) == 0 {
req.Header.Set("User-Agent", "containerd/"+version.Version)
}

resp, err := ctxhttp.Do(ctx, ah.client, req)
if err != nil {
Expand Down Expand Up @@ -408,6 +412,9 @@ func (ah *authHandler) fetchToken(ctx context.Context, to tokenOptions) (string,
req.Header[k] = append(req.Header[k], v...)
}
}
if len(req.Header.Get("User-Agent")) == 0 {
req.Header.Set("User-Agent", "containerd/"+version.Version)
}

reqParams := req.URL.Query()

Expand Down

0 comments on commit e4418db

Please sign in to comment.