Re-visit basic auth protected registry (#53)

Using a registry having basic auth enabled the authentication was not
submitted to Clair. This newly introduced error fixes the missing auth
but needs testing with non-basic auth protected registries.

Also maybe the test for the "malformed auth..." string can now be
removed as it does not trigger on registries with basic auth enabled?

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2018-06-06 18:38:23 +02:00 committed by Jess Frazelle
parent f813f306c0
commit f7bf33b7a6
2 changed files with 2 additions and 2 deletions

View file

@ -101,7 +101,7 @@ func (c *Clair) NewClairLayer(r *registry.Registry, image string, fsLayers []sch
if err != nil {
// if we get an error here of type: malformed auth challenge header: 'Basic realm="Registry Realm"'
// we need to use basic auth for the registry
if !strings.Contains(err.Error(), `malformed auth challenge header: 'Basic realm="Registry`) {
if !strings.Contains(err.Error(), `malformed auth challenge header: 'Basic realm="Registry`) && err.Error() != "basic auth required" {
return nil, err
}
useBasicAuth = true

View file

@ -25,7 +25,7 @@ func parseAuthHeader(header http.Header) (*authService, error) {
func parseChallenge(challengeHeader string) (*authService, error) {
if basicRegex.MatchString(challengeHeader) {
return nil, nil
return nil, fmt.Errorf("basic auth required")
}
match := bearerRegex.FindAllStringSubmatch(challengeHeader, -1)