fix: correct authentication for ghcr.io registry(#349)

Co-authored-by: Martin <Junkern@users.noreply.github.com>
This commit is contained in:
Alexander Niebuhr 2022-06-16 19:47:17 +02:00 committed by GitHub
parent 0beb476c08
commit 3c22540321
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -4,6 +4,7 @@ import (
"context"
"crypto/sha256"
"crypto/tls"
b64 "encoding/base64"
"encoding/json"
"fmt"
"io/ioutil"
@ -101,7 +102,11 @@ func getImageDigest(registry, image, tag, username, password string, insecureSki
}
if username != "" {
if registry != "ghcr.io" {
req.SetBasicAuth(username, password)
} else {
req.Header.Add("Authorization", "Bearer "+b64.StdEncoding.EncodeToString([]byte(password)))
}
}
// We accept schema v2 manifests and manifest lists, and also OCI types