@@ -432,7 +432,7 @@ func (r *OCIRepositoryReconciler) reconcileSource(ctx context.Context, sp *patch
432
432
conditions .GetObservedGeneration (obj , sourcev1 .SourceVerifiedCondition ) != obj .Generation ||
433
433
conditions .IsFalse (obj , sourcev1 .SourceVerifiedCondition ) {
434
434
435
- err := r .verifySignature (ctx , obj , ref , opts ... )
435
+ err := r .verifySignature (ctx , obj , ref , keychain , auth , opts ... )
436
436
if err != nil {
437
437
provider := obj .Spec .Verify .Provider
438
438
if obj .Spec .Verify .SecretRef == nil {
@@ -613,7 +613,7 @@ func (r *OCIRepositoryReconciler) digestFromRevision(revision string) string {
613
613
// verifySignature verifies the authenticity of the given image reference URL.
614
614
// First, it tries to use a key if a Secret with a valid public key is provided.
615
615
// If not, it falls back to a keyless approach for verification.
616
- func (r * OCIRepositoryReconciler ) verifySignature (ctx context.Context , obj * ociv1.OCIRepository , ref name.Reference , opt ... remote.Option ) error {
616
+ func (r * OCIRepositoryReconciler ) verifySignature (ctx context.Context , obj * ociv1.OCIRepository , ref name.Reference , keychain authn. Keychain , auth authn. Authenticator , opt ... remote.Option ) error {
617
617
ctxTimeout , cancel := context .WithTimeout (ctx , obj .Spec .Timeout .Duration )
618
618
defer cancel ()
619
619
@@ -718,31 +718,6 @@ func (r *OCIRepositoryReconciler) verifySignature(ctx context.Context, obj *ociv
718
718
soci .WithNotaryRemoteOptions (opt ... ),
719
719
}
720
720
721
- keychain , err := r .keychain (ctx , obj )
722
- if err != nil {
723
- e := serror .NewGeneric (
724
- fmt .Errorf ("failed to get credential: %w" , err ),
725
- sourcev1 .AuthenticationFailedReason ,
726
- )
727
- conditions .MarkTrue (obj , sourcev1 .FetchFailedCondition , e .Reason , e .Err .Error ())
728
- return e
729
- }
730
-
731
- var auth authn.Authenticator
732
-
733
- if _ , ok := keychain .(soci.Anonymous ); obj .Spec .Provider != ociv1 .GenericOCIProvider && ok {
734
- var authErr error
735
- auth , authErr = soci .OIDCAuth (ctxTimeout , obj .Spec .URL , obj .Spec .Provider )
736
- if authErr != nil && ! errors .Is (authErr , oci .ErrUnconfiguredProvider ) {
737
- e := serror .NewGeneric (
738
- fmt .Errorf ("failed to get credential from %s: %w" , obj .Spec .Provider , authErr ),
739
- sourcev1 .AuthenticationFailedReason ,
740
- )
741
- conditions .MarkTrue (obj , sourcev1 .FetchFailedCondition , e .Reason , e .Err .Error ())
742
- return e
743
- }
744
- }
745
-
746
721
for k , data := range pubSecret .Data {
747
722
if strings .HasSuffix (k , ".crt" ) || strings .HasSuffix (k , ".pem" ) {
748
723
verifier , err := soci .NewNotaryVerifier (append (defaultNotaryOciOpts , soci .WithNotaryPublicCertificate (data ), soci .WithNotaryAuth (auth ), soci .WithNotaryKeychain (keychain ), soci .WithInsecureRegistry (obj .Spec .Insecure ))... )
0 commit comments