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

Reduce required permissions for the GCPCKMS auto-unsealer #5999

Merged
merged 1 commit into from
Jan 4, 2019
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
17 changes: 7 additions & 10 deletions vault/seal/gcpckms/gcpckms.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,18 +140,15 @@ func (s *GCPCKMSSeal) SetConfig(config map[string]string) (map[string]string, er
if err != nil {
return nil, errwrap.Wrapf("error initializing GCP CKMS seal client: {{err}}", err)
}
s.client = kmsClient

// Make sure cryto key exists in GCP
keyInfo, err := kmsClient.Projects.Locations.KeyRings.CryptoKeys.Get(s.parentName).Do()
if err != nil {
return nil, errwrap.Wrapf("error fetching GCP CKMS seal key information: {{err}}", err)
}
if keyInfo == nil {
return nil, errors.New("no key information returned")
// Make sure user has permissions to encrypt (also checks if key exists)
ctx := context.Background()
if _, err := s.Encrypt(ctx, []byte("vault-gcpckms-test")); err != nil {
return nil, errwrap.Wrapf("failed to encryot with GCP CKMS - ensure the "+
sethvargo marked this conversation as resolved.
Show resolved Hide resolved
"key exists and the service account has at least "+
"roles/cloudkms.cryptoKeyEncrypterDecrypter permission: {{err}", err)
}
s.currentKeyID.Store(keyInfo.Name)

s.client = kmsClient
}

// Map that holds non-sensitive configuration info to return
Expand Down
24 changes: 19 additions & 5 deletions website/source/docs/configuration/seal/gcpckms.html.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ These parameters apply to the `seal` stanza in the Vault configuration file:
encryption and decryption. May also be specified by the
`VAULT_GCPCKMS_SEAL_CRYPTO_KEY` environment variable.

## Authentication
## Authentication & Permissions

Authentication-related values must be provided, either as environment
variables or as configuration parameters.
Expand All @@ -76,6 +76,20 @@ credentials, environment credentials, or [application default
credentials](https://developers.google.com/identity/protocols/application-default-credentials)
in that order, if the above GCP specific values are not provided.

The service account needs the following minimum permissions on the crypto key:

```text
cloudkms.cryptoKeyVersions.useToEncrypt
cloudkms.cryptoKeyVersions.useToDecrypt
```

these permissions are available as part of the following role:

```text
roles/cloudkms.cryptoKeyEncrypterDecrypter
```


## `gcpckms` Environment Variables

Alternatively, the GCP Cloud KMS seal can be activated by providing the following
Expand All @@ -89,8 +103,8 @@ environment variables:

## Key Rotation

This seal supports rotating keys defined in Google Cloud KMS
[doc](https://cloud.google.com/kms/docs/rotating-keys). Both scheduled rotation and manual
rotation is supported for CKMS since the key information. Old keys version must not be
disabled or deleted and are used to decrypt older data. Any new or updated data will be
This seal supports rotating keys defined in Google Cloud KMS
[doc](https://cloud.google.com/kms/docs/rotating-keys). Both scheduled rotation and manual
rotation is supported for CKMS since the key information. Old keys version must not be
disabled or deleted and are used to decrypt older data. Any new or updated data will be
encrypted with the primary key version.