Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

verifier: Get local authenticator struct to return a usable authenticator #3318

Merged
merged 1 commit into from
May 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion internal/verifier/sigstore/container/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@ type containerAuth struct {
ghClient provifv1.GitHub
}

func (c *containerAuth) getAuthenticator(owner string) authn.Authenticator {
if c.ghClient != nil {
return c.ghClient.GetCredential().GetAsContainerAuthenticator(owner)
}
return authn.Anonymous
}

func newContainerAuth(authOpts ...AuthMethod) *containerAuth {
var auth containerAuth
for _, opt := range authOpts {
Expand Down Expand Up @@ -166,7 +173,7 @@ func getSigstoreBundles(
) ([]sigstoreBundle, error) {
imageRef := BuildImageRef(registry, owner, artifact, version)
// Try to build a bundle from the OCI image reference
bundles, err := bundleFromOCIImage(ctx, imageRef, auth.ghClient.GetCredential().GetAsContainerAuthenticator(owner))
bundles, err := bundleFromOCIImage(ctx, imageRef, auth.getAuthenticator(owner))
if errors.Is(err, ErrProvenanceNotFoundOrIncomplete) && auth.ghClient != nil {
// If we failed to find the signature in the OCI image, try to build a bundle from the GitHub attestation endpoint
return bundleFromGHAttestationEndpoint(ctx, auth.ghClient, owner, version)
Expand Down