utils

package
v0.0.0-...-05d41a9 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// AuthMethodKubernetes is a named auth method.
	AuthMethodKubernetes = "kubernetes"
	// AuthMethodApprole
	AuthMethodAppRole = "approle"
	// AuthMethod is a vault authentication method used.
	// https://www.vaultproject.io/docs/auth#auth-methods
	AuthMethod = "VAULT_AUTH_METHOD"
	// AuthMountPath defines a custom auth mount path.
	AuthMountPath = "VAULT_AUTH_MOUNT_PATH"
	// AuthKubernetesRole is the role to authenticate against on Vault
	AuthKubernetesRole = "VAULT_AUTH_KUBERNETES_ROLE"
	// AuthKubernetesTokenPath is the file path to a custom JWT token to use for authentication.
	// If omitted, the default service account token path is used.
	AuthKubernetesTokenPath = "VAULT_AUTH_KUBERNETES_TOKEN_PATH"
	// AuthKubernetesMountPath
	AuthKubernetesMountPath = "kubernetes"
	// AuthAppRoleRoleID
	AuthAppRoleRoleID = "VAULT_APPROLE_ROLE_ID"
	// AuthAppRoleSecretID
	AuthAppRoleSecretID = "VAULT_APPROLE_SECRET_ID"
)

Variables

View Source
var (
	ErrVaultAuthParamsNotSet = errors.New("VAULT_TOKEN or VAULT_AUTH_METHOD not set")
	ErrVaultAddressNotSet    = errors.New("VAULT_ADDR not set")
	ErrInvalidVaultToken     = errors.New("VAULT_TOKEN is invalid")
	ErrInvalidSkipVerify     = errors.New("VAULT_SKIP_VERIFY is invalid")
	ErrAppRoleIDNotSet       = errors.New("VAULT_APPROLE_ROLE_ID or VAULT_APPROLE_SECRET_ID not set")
	ErrInvalidVaultAddress   = errors.New("VAULT_ADDRESS is invalid. " +
		"Should be of the form http(s)://<ip>:<port>")

	ErrAuthMethodUnknown = errors.New("unknown auth method")
	ErrKubernetesRole    = errors.New(AuthKubernetesRole + " not set")
	ErrInCooldown        = errors.New("vault client is in cooldown")
)

Functions

func Authenticate

func Authenticate(client *api.Client, config map[string]interface{}) (token string, autoAuth bool, err error)

Authenticate gets vault authentication parameters for the provided configuration.

func CloseIdleConnections

func CloseIdleConnections(cfg *api.Config)

CloseIdleConnections ensures that the vault idle connections are closed.

func ConfigureTLS

func ConfigureTLS(config *api.Config, secretConfig map[string]interface{}) error

ConfigureTLS adds tls parameters to the vault configuration.

func GetAuthToken

func GetAuthToken(client *api.Client, config map[string]interface{}) (string, error)

GetAuthToken tries to get the vault token for the provided authentication method.

func GetVaultParam

func GetVaultParam(secretConfig map[string]interface{}, name string) string

GetVaultParam retrieves a named parameter from the config or tried to get it from the environment variables.

func IsValidAddr

func IsValidAddr(address string) error

IsValidAddr checks address has the correct format.

Types

This section is empty.

Jump to

Keyboard shortcuts

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