Skip to content

Introduce Vault KVv2 secret storage support#68

Open
kelnage wants to merge 4 commits intografana:mainfrom
kelnage:kelnage/vault-secret-support
Open

Introduce Vault KVv2 secret storage support#68
kelnage wants to merge 4 commits intografana:mainfrom
kelnage:kelnage/vault-secret-support

Conversation

@kelnage
Copy link
Copy Markdown
Contributor

@kelnage kelnage commented Dec 23, 2025

Adds support for fetching secrets (the USERNAME, PASSWORD, and BEARER_TOKEN) from a configured Vault KVv2 mount path. It uses the IAM authentication approaches described in the Vault AWS auth documentation, and the implementation is partly built around the provided code example.

It extends the the secret client to store both the Vault configuration (role, mount, and path) and a cache of the fetched secret data, in order to minimise time fetching environment variables and requests to Vault.

If this implementation seems reasonable, I'd be happy to update the documentation to reflect its intended usage.

Copy link
Copy Markdown
Collaborator

@jeschkies jeschkies left a comment

Choose a reason for hiding this comment

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

This is a really nice solution. I just think we need to overhaul the credentials providers.

pkg/env.go Outdated
Comment on lines 11 to 17
type secretFetcher interface {
FetchFromAWSSecretsManager(ctx context.Context, secretArn string) (string, error)
FetchFromAWSSSMParameterStore(ctx context.Context, parameterArn string) (string, error)
FetchFromVault(ctx context.Context, key string) (string, error)
HasVaultConfig() bool
SetVaultConfig(config *VaultKVCredentials)
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I wonder if we should change it so that the fetcher is injected in main depending on the config. This way we don't need HasVaultConfig. We could also mimic the credentials chain like in AWS. We define a Provider interface and then implement each plus a ChainProvider.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I've had a go at building what you suggest in 034da68 - let me know if it aligns with what you were thinking!

pkg/secrets.go Outdated
return "", fmt.Errorf("no auth info was returned after login")
}

data, err := client.KVv2(c.vaultConfig.mount).Get(ctx, c.vaultConfig.path)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I would have thought that Vault would call an API. Is this actually mounting a volume? Also, this only works if Vault is also hosted on AWS right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think this is a terminology issue - Vault refers to the top-level list of Vaults as "mounts" (see this documentation). No volume mounting involved :) And yes, the AWS auth method only works if Vault is hosted on AWS.

Breaks the secretFilter interface into multiple providers, allowing a
chained application of them, where applicable. Update unit tests to
reflect the new behavior.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants