Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions app/controlplane/internal/service/ocirepository.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ func (s *OCIRepositoryService) Save(ctx context.Context, req *pb.OCIRepositorySe
username := req.GetKeyPair().Username
password := req.GetKeyPair().Password

// Create credentials
// Create and validate credentials
k, err := ociauth.NewCredentials(req.Repository, username, password)
if err != nil {
return nil, sl.LogAndMaskErr(err, s.log)
return nil, errors.BadRequest("wrong credentials", err.Error())
}

// Check credentials
Expand Down
3 changes: 2 additions & 1 deletion internal/ociauth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package ociauth

import (
"errors"
"fmt"

"github.com/google/go-containerregistry/pkg/authn"
"github.com/google/go-containerregistry/pkg/name"
Expand All @@ -31,7 +32,7 @@ type Credentials struct {
func NewCredentials(repoURI, username, password string) (authn.Keychain, error) {
repo, err := name.NewRepository(repoURI)
if err != nil {
return nil, err
return nil, fmt.Errorf("invalid repository URI: %w", err)
}

// NOTE: NewRepository parses incorrectly URIs with schemas
Expand Down