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

remote.vault: introduce component to retrieve secrets from Vault #3428

Merged
merged 15 commits into from
May 8, 2023

Conversation

rfratto
Copy link
Member

@rfratto rfratto commented Apr 3, 2023

The remote.vault component retrieves secrets from Vault. The initial implementation is scoped to only retrieving secrets from the KVv2 store, but it should be flexible enough to support logical database stores in the future.

remote.vault supports a few different authentication methods, all from the Vault API module:

  • Raw Token
  • Approle
  • AWS
  • Azure
  • GCP
  • Kubernetes
  • LDAP
  • Username/password
  • Custom

Authentication tokens are automatically refreshed in the background if they have a lease or are renewable.

Currently, the entire set of data retrieved from Vault is treated as a secret, and there is no way to mark a key from the data as non-sensitive. In the future, this may be handled by some kind of function to convert a secret into a string, or a configuration block in the component to list a subset of data field names as non-sensitive.

When reviewing, note that the prototype for this one started in the extremely early days of Flow (e.g., pre-v0.28). There may be best practices I'm not following, and didn't catch in my self-review. If you notice anything out of place, please let me know.

Sorry about the size of this one 😞

Copy link
Member Author

@rfratto rfratto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prototyped this a long time ago and finally got around to pushing it now. Leaving comments for patterns that have changed in our documentation structure.

@rfratto rfratto force-pushed the remote.vault branch 4 times, most recently from 949c053 to 0303314 Compare April 29, 2023 18:27
rfratto added 4 commits April 29, 2023 15:25
The remote.vault component retrieves secrets from Vault.
Add end-to-end tests using testcontainers-go. This required a lot of
(unfortunate) go.mod trickery.
@rfratto rfratto marked this pull request as ready for review April 29, 2023 19:58
@rfratto rfratto changed the title [WIP] remote.vault: introduce component to retrieve secrets from Vault remote.vault: introduce component to retrieve secrets from Vault Apr 29, 2023
Comment on lines +14 to +22
k3d_client "github.com/k3d-io/k3d/v5/pkg/client"
config "github.com/k3d-io/k3d/v5/pkg/config"
k3d_cfgtypes "github.com/k3d-io/k3d/v5/pkg/config/types"
k3d_config "github.com/k3d-io/k3d/v5/pkg/config/v1alpha4"
k3d_log "github.com/k3d-io/k3d/v5/pkg/logger"
k3d_runtime "github.com/k3d-io/k3d/v5/pkg/runtimes"
k3d_docker "github.com/k3d-io/k3d/v5/pkg/runtimes/docker"
k3d_types "github.com/k3d-io/k3d/v5/pkg/types"
k3d_version "github.com/k3d-io/k3d/v5/version"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These had to be updated to sort out dependency hell 😬

@rfratto rfratto requested review from mattdurham and tpaschalis May 2, 2023 15:32
Copy link
Member

@tpaschalis tpaschalis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haven't put it to work versus an actual Vault instance to be honest; but looks good except for some minor points.

}

// AuthAWS authenticates against Vault with AWS.
type AuthAWS struct {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems that upstream passes some default values, should we follow suit? Also, there's a withNonce method we're not using, not sure if it was left out on purpose.

https://github.com/hashicorp/vault/blob/api/auth/aws/v0.4.0/api/auth/aws/aws.go#L59-L62

Copy link
Member Author

@rfratto rfratto May 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left nonce out on purpose, I don't think it makes sense to set a static nonce for the lifetime of the component, since the idea of a nonce is that it's used just once.

Copy link
Collaborator

@mattdurham mattdurham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found some issues with attr naming and questions about naming.

@rfratto rfratto requested review from tpaschalis and mattdurham May 5, 2023 17:49
Copy link
Collaborator

@mattdurham mattdurham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome LGTM

Copy link
Member

@tpaschalis tpaschalis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@rfratto rfratto merged commit 9e93184 into grafana:main May 8, 2023
@rfratto rfratto deleted the remote.vault branch May 8, 2023 18:35
clayton-cornell pushed a commit that referenced this pull request Aug 14, 2023
The remote.vault component retrieves secrets from Vault.

Co-authored-by: Paschalis Tsilias <[email protected]>
clayton-cornell pushed a commit that referenced this pull request Aug 14, 2023
The remote.vault component retrieves secrets from Vault.

Co-authored-by: Paschalis Tsilias <[email protected]>
@github-actions github-actions bot added the frozen-due-to-age Locked due to a period of inactivity. Please open new issues or PRs if more discussion is needed. label Feb 26, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
frozen-due-to-age Locked due to a period of inactivity. Please open new issues or PRs if more discussion is needed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants