vaultcredentials

package
v1.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 31, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultMapper

func DefaultMapper(s string) (*store.Credential, error)

DefaultMapper maps the default username/password structure returned from the Vault API.

func GetFromVaultSecretsAPI

func GetFromVaultSecretsAPI(ctx context.Context, client *vault.Client, mountPath string, path string) (string, error)

GetFromVaultSecretsAPI is a wrapper over logical reads from a Vault path with marshalling and error handling.

Types

type APIDatabaseCredentials

type APIDatabaseCredentials struct {
	// contains filtered or unexported fields
}

APIDatabaseCredentials gets DB credentials from the Vault Database Secrets engine See: https://www.vaultproject.io/docs/secrets/databases/

func (*APIDatabaseCredentials) GetCredentials

func (db *APIDatabaseCredentials) GetCredentials(ctx context.Context, client *vault.Client) (string, error)

GetCredentials implements the CredentialLocation interface.

func (*APIDatabaseCredentials) Map

Map implements the CredentialLocation interface.

type AgentDatabaseCredentials

type AgentDatabaseCredentials struct {
	// contains filtered or unexported fields
}

AgentDatabaseCredentials gets DB credentials the Vault Agent creates on disk See: https://www.vaultproject.io/docs/agent/index.html One of the key features of the Vault agent is that it can spit out credentials using Consul template markup. See https://www.vaultproject.io/docs/agent/template for details.

func (*AgentDatabaseCredentials) GetCredentials

func (adb *AgentDatabaseCredentials) GetCredentials(_ context.Context, _ *vault.Client) (string, error)

GetCredentials implements the CredentialLocation interface.

func (*AgentDatabaseCredentials) Map

Map implements the CredentialLocation interface.

type CredentialLocation

type CredentialLocation interface {
	GetCredentials(ctx context.Context, client *vault.Client) (string, error)
	Map(s string) (*store.Credential, error)
}

CredentialLocation represents a location where credentials can be retrieved from.

func NewAPIDatabaseCredentials

func NewAPIDatabaseCredentials(role, path string) CredentialLocation

NewAPIDatabaseCredentials creates a new credential location backed by Vault's DB Secrets engine.

The path argument will be mostly unused unless the user mounts the database backend in a different location.

func NewAgentDatabaseCredentials

func NewAgentDatabaseCredentials(mapper Mapper, path string) CredentialLocation

NewAgentDatabaseCredentials creates a new AgentDatabaseCredentials instance.

func NewKvCredentials

func NewKvCredentials(mountPath string, path string) CredentialLocation

NewKvCredentials retrieves credentials from Vault's K/V store.

type Credentials

type Credentials interface {
	GetUsername() string
	GetPassword() string
}

Credentials represents an abstraction over a username and password.

type KvCredentials

type KvCredentials struct {
	// contains filtered or unexported fields
}

KvCredentials implements the CredentialLocation interface.

func (*KvCredentials) GetCredentials

func (kv *KvCredentials) GetCredentials(ctx context.Context, client *vault.Client) (string, error)

GetCredentials implements the CredentialLocation interface.

func (*KvCredentials) Map

Map implements the CredentialLocation interface.

type Mapper

type Mapper func(s string) (*store.Credential, error)

Map handles mapping data from a file on disk to a Credentials object. This allows consumers to define how their credential data is structured.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL