Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
f919052
feat: add GCP secrect manager support - the code handling GCP integra…
gr0 May 22, 2023
5fd5faa
feat: add GCP secrect manager support - CLI support for controlplane
gr0 May 22, 2023
0d8c81b
feat: add GCP secrect manager support - support for artifact-cas
gr0 May 22, 2023
660d168
Lint
gr0 May 23, 2023
6762a66
fix: downgrade GRPC to 1.54.0 to avoid problems with dependencies
gr0 May 23, 2023
6366ab5
chore(ci): check go mod tidiness (#126)
migmartri May 23, 2023
fb779a9
fix: move marshaling to the beginning of the function to fail fast if…
gr0 May 25, 2023
68d0faf
feat: improve logging for GCP secret manager
gr0 May 25, 2023
7d6610f
fix(docs): add information about support for GCP Secres Manager to CA…
gr0 May 25, 2023
a7b75c2
Merge branch 'main' into rafal/add-support-for-gcp-secret-manager
gr0 May 25, 2023
ce48562
fix: remove the check when initializing credentials manager
gr0 May 25, 2023
15bb5af
fix: initialize logger in tests
gr0 May 25, 2023
d61212d
fix: remove the unused Close() function from GCP secrets manager and …
gr0 May 25, 2023
3613713
fix: provide an example configuration and use key instead of passing …
gr0 May 25, 2023
4739865
fix: add support for secret prefix in GCP and use the gRPC client
gr0 May 25, 2023
93f62a1
fix: logging adjustment
gr0 May 25, 2023
be5c440
fix: rename the configuration related the GCP key'
gr0 May 25, 2023
3088ab7
fix: avoid checking for existence of the secret before deletion
gr0 May 25, 2023
27c3f38
fix: remove extra lines
gr0 May 25, 2023
fc87113
fix: improve docs and check for credentials reader configuration
gr0 May 26, 2023
0927225
fix: improve tests and make the key empty
gr0 May 26, 2023
49cd080
fix: improve tests and use redacted key
gr0 May 26, 2023
ec456df
fix: redact the key used in unit tests to make sure it is clear the k…
gr0 May 26, 2023
335789b
fix: typo correct
gr0 May 26, 2023
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
2 changes: 1 addition & 1 deletion app/artifact-cas/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Its structure contains the following top to down layers.

## System Dependencies

The CAS proxy **has only one running dependency**. A secret storage backend to retrieve the OCI repository credentials. Currently, we support both [Hashicorp Vault](https://www.vaultproject.io/) and [AWS Secret Manager](https://aws.amazon.com/secrets-manager/).
The CAS proxy **has only one running dependency**. A secret storage backend to retrieve the OCI repository credentials. Currently, we support [Hashicorp Vault](https://www.vaultproject.io/), [AWS Secret Manager](https://aws.amazon.com/secrets-manager/) AND [GCP Secret Manager](https://cloud.google.com/secret-manager).

This secret backend is used to download OCI repository credentials (repository path + key pair) during upload/downloads. This makes the Artifact CAS multi-tenant by default since the destination OCI backend gets selected at runtime.

Expand Down
37 changes: 30 additions & 7 deletions app/artifact-cas/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (

"github.com/chainloop-dev/chainloop/internal/credentials"
awssecrets "github.com/chainloop-dev/chainloop/internal/credentials/aws"
"github.com/chainloop-dev/chainloop/internal/credentials/gcp"
"github.com/chainloop-dev/chainloop/internal/credentials/vault"
"github.com/getsentry/sentry-go"

Expand Down Expand Up @@ -125,18 +126,20 @@ func main() {
}

func newCredentialsReader(conf *conf.Credentials, l log.Logger) (credentials.Reader, error) {
awsc, vaultc := conf.GetAwsSecretManager(), conf.GetVault()
if awsc == nil && vaultc == nil {
awsc, vaultc, gcpc := conf.GetAwsSecretManager(), conf.GetVault(), conf.GetGcpSecretManager()
if awsc == nil && vaultc == nil && gcpc == nil {
return nil, errors.New("no credentials manager configuration found")
} else if awsc != nil && vaultc != nil {
return nil, errors.New("only one credentials manager can be configured")
}

if c := conf.GetAwsSecretManager(); c != nil {
return newAWSCredentialsManager(c, l)
if awsc != nil {
return newAWSCredentialsManager(awsc, l)
}

return newVaultCredentialsManager(conf.GetVault(), l)
if gcpc != nil {
return newGCPCredentialsManager(gcpc, l)
}

return newVaultCredentialsManager(vaultc, l)
}

func newAWSCredentialsManager(conf *conf.Credentials_AWSSecretManager, l log.Logger) (*awssecrets.Manager, error) {
Expand Down Expand Up @@ -180,6 +183,26 @@ func newVaultCredentialsManager(conf *conf.Credentials_Vault, l log.Logger) (*va
return m, nil
}

func newGCPCredentialsManager(conf *conf.Credentials_GCPSecretManager, l log.Logger) (*gcp.Manager, error) {
if conf == nil {
return nil, errors.New("uncompleted configuration for GCP secret manager")
}

opts := &gcp.NewManagerOpts{
ProjectID: conf.ProjectId,
ServiceAccountKey: conf.ServiceAccountKey,
SecretPrefix: conf.SecretPrefix,
Logger: l,
}

m, err := gcp.NewManager(opts)
if err != nil {
return nil, fmt.Errorf("configuring the GCP secret manager: %w", err)
}

return m, nil
}

func initSentry(c *conf.Bootstrap, logger log.Logger) (cleanupFunc func(), err error) {
cleanupFunc = func() {
sentry.Flush(2 * time.Second)
Expand Down
5 changes: 5 additions & 0 deletions app/artifact-cas/configs/samples/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,8 @@ observability:
sentry:
dsn: "http://sentryDomain"
environment: development # production

## gcp_secret_manager:
## project_id: 522312304548
## auth_key: "./configs/gcp_auth_key.json"
## secret_prefix: "pre-"
190 changes: 149 additions & 41 deletions app/artifact-cas/internal/conf/conf.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading