Documentation
¶
Index ¶
- Constants
- func GenerateMasterKey() (string, error)
- func NewMockAdapter() (SecureStorage, *MockAdapter)
- func SaveSecrets(jsonFile string, store map[string]string) error
- type AuthConfig
- type InputDelete
- type InputLookup
- type InputLookupKeys
- type InputStore
- type LocalStore
- func (l *LocalStore) Delete(key string) error
- func (l *LocalStore) Lookup(key string, output interface{}) error
- func (l *LocalStore) LookupKeys(keyPath string) ([]string, error)
- func (l *LocalStore) Store(key string, value interface{}) error
- func (l *LocalStore) StoreWithData(key string, value interface{}, output interface{}) error
- type MockAdapter
- func (ss *MockAdapter) Delete(key string) error
- func (ss *MockAdapter) Lookup(key string, output interface{}) error
- func (ss *MockAdapter) LookupKeys(keyPath string) ([]string, error)
- func (ss *MockAdapter) Store(key string, value interface{}) error
- func (ss *MockAdapter) StoreWithData(key string, value interface{}, output interface{}) error
- type MockDelete
- type MockLookup
- type MockLookupKeys
- type MockStore
- type MockStoreWithData
- type OutputDelete
- type OutputLookup
- type OutputLookupKeys
- type OutputStore
- type RealVaultApi
- func (v *RealVaultApi) Delete(path string) (*api.Secret, error)
- func (v *RealVaultApi) List(path string) (*api.Secret, error)
- func (v *RealVaultApi) Read(path string) (*api.Secret, error)
- func (v *RealVaultApi) SetToken(t string)
- func (v *RealVaultApi) Write(path string, data map[string]interface{}) (*api.Secret, error)
- type SecureStorage
- type VaultAdapter
- func (ss *VaultAdapter) Delete(key string) error
- func (ss *VaultAdapter) Lookup(key string, output interface{}) error
- func (ss *VaultAdapter) LookupKeys(keyPath string) ([]string, error)
- func (ss *VaultAdapter) Store(key string, value interface{}) error
- func (ss *VaultAdapter) StoreWithData(key string, value interface{}, output interface{}) error
- type VaultApi
Constants ¶
const DefaultBasePath = "secret"
const EnvVaultAuthPath = "CRAY_VAULT_AUTH_PATH"
const EnvVaultJWTFile = "CRAY_VAULT_JWT_FILE"
These Env var are provided globally to pods
const EnvVaultRoleFile = "CRAY_VAULT_ROLE_FILE"
Variables ¶
This section is empty.
Functions ¶
func GenerateMasterKey ¶ added in v1.18.0
GenerateMasterKey creates a 32-byte random key and returns it as a hex string.
func NewMockAdapter ¶
func NewMockAdapter() (SecureStorage, *MockAdapter)
Types ¶
type AuthConfig ¶
type AuthConfig struct {
JWTFile string
RoleFile string
Path string
// contains filtered or unexported fields
}
AuthConfig struct for vault k8s authentication
func DefaultAuthConfig ¶
func DefaultAuthConfig() *AuthConfig
DefaultAuthConfig Create the default auth config that will work for almost all scenarios
func (*AuthConfig) GetAuthArgs ¶
func (authConfig *AuthConfig) GetAuthArgs() map[string]interface{}
GetAuthArgs generates the ars required for generating an auth token
func (*AuthConfig) GetAuthPath ¶
func (authConfig *AuthConfig) GetAuthPath() string
GetAuthPath Getter for auth path key
func (*AuthConfig) LoadJWT ¶
func (authConfig *AuthConfig) LoadJWT() error
LoadJWT save contents of JWTFile to the jwt field
func (*AuthConfig) LoadRole ¶
func (authConfig *AuthConfig) LoadRole() error
LoadRole save contents of RoleFile to the role field
func (*AuthConfig) ReadEnvironment ¶
func (authConfig *AuthConfig) ReadEnvironment() error
ReadEnvironment Update an authConfig with environment variables
type InputDelete ¶
type InputDelete struct {
Key string
}
type InputLookup ¶
type InputLookup struct {
Key string
}
type InputLookupKeys ¶
type InputLookupKeys struct {
KeyPath string
}
type InputStore ¶
type InputStore struct {
Key string
Value interface{}
}
type LocalStore ¶ added in v1.18.0
type LocalStore struct {
Secrets map[string]string `json:"secrets"`
// contains filtered or unexported fields
}
Structure to store encrypted secrets in a JSON file
func NewLocalSecretStore ¶ added in v1.18.0
func NewLocalSecretStore(masterKeyHex, filename string, create bool) (*LocalStore, error)
func (*LocalStore) Delete ¶ added in v1.18.0
func (l *LocalStore) Delete(key string) error
Delete removes a secret by its key from the local store
func (*LocalStore) Lookup ¶ added in v1.18.0
func (l *LocalStore) Lookup(key string, output interface{}) error
Lookup retrieves a secret by its key, decrypting it with AES-GCM
func (*LocalStore) LookupKeys ¶ added in v1.18.0
func (l *LocalStore) LookupKeys(keyPath string) ([]string, error)
LookupKeys retrieves all keys from the local store and ignores the keyPath parameter which doesn't make sense here It returns a slice of keys stored in the local secret store.
func (*LocalStore) Store ¶ added in v1.18.0
func (l *LocalStore) Store(key string, value interface{}) error
Store saves a secret in the local store, encrypting it with AES-GCM The key is used to derive a unique AES key for each secret The value is expected to be a map that will be marshaled to JSON It reloads the contents of the file if they have changed since the last read If the key already exists, it will be overwritten If the value is nil, an error will be returned
func (*LocalStore) StoreWithData ¶ added in v1.18.0
func (l *LocalStore) StoreWithData(key string, value interface{}, output interface{}) error
StoreWithData is part of the SecureStorage interface and is not implemented in LocalSecretStore.
type MockAdapter ¶
type MockAdapter struct {
StoreNum int
StoreData []MockStore
StoreWDataNum int
StoreWData []MockStoreWithData
LookupNum int
LookupData []MockLookup
DeleteNum int
DeleteData []MockDelete
LookupKeysNum int
LookupKeysData []MockLookupKeys
}
func (*MockAdapter) Delete ¶
func (ss *MockAdapter) Delete(key string) error
func (*MockAdapter) Lookup ¶
func (ss *MockAdapter) Lookup(key string, output interface{}) error
func (*MockAdapter) LookupKeys ¶
func (ss *MockAdapter) LookupKeys(keyPath string) ([]string, error)
func (*MockAdapter) Store ¶
func (ss *MockAdapter) Store(key string, value interface{}) error
func (*MockAdapter) StoreWithData ¶ added in v1.13.0
func (ss *MockAdapter) StoreWithData(key string, value interface{}, output interface{}) error
type MockDelete ¶
type MockDelete struct {
Input InputDelete
Output OutputDelete
}
type MockLookup ¶
type MockLookup struct {
Input InputLookup
Output OutputLookup
}
type MockLookupKeys ¶
type MockLookupKeys struct {
Input InputLookupKeys
Output OutputLookupKeys
}
type MockStore ¶
type MockStore struct {
Input InputStore
Output OutputStore
}
type MockStoreWithData ¶ added in v1.13.0
type MockStoreWithData struct {
Input InputStore
Output OutputLookup
}
type OutputDelete ¶
type OutputDelete struct {
Err error
}
type OutputLookup ¶
type OutputLookup struct {
Output interface{}
Err error
}
type OutputLookupKeys ¶
type OutputStore ¶
type OutputStore struct {
Err error
}
type RealVaultApi ¶
func (*RealVaultApi) SetToken ¶
func (v *RealVaultApi) SetToken(t string)
type SecureStorage ¶
type SecureStorage interface {
Store(key string, value interface{}) error
StoreWithData(key string, value interface{}, output interface{}) error
Lookup(key string, output interface{}) error
Delete(key string) error
LookupKeys(keyPath string) ([]string, error)
}
func NewVaultAdapter ¶
func NewVaultAdapter(basePath string) (SecureStorage, error)
Create a new SecureStorage interface that uses Vault. This connects to vault.
func NewVaultAdapterAs ¶ added in v1.13.0
func NewVaultAdapterAs(basePath string, role string) (SecureStorage, error)
type VaultAdapter ¶
type VaultAdapter struct {
Config *api.Config
Client VaultApi
AuthConfig *AuthConfig
BasePath string
VaultRetry int
Role string
}
func (*VaultAdapter) Delete ¶
func (ss *VaultAdapter) Delete(key string) error
Remove a struct from Vault at the location specified by key. This function prepends the basePath. Retries are implemented for token renewal.
func (*VaultAdapter) Lookup ¶
func (ss *VaultAdapter) Lookup(key string, output interface{}) error
Read a struct from Vault at the location specified by key. This function prepends the basePath. Retries are implemented for token renewal.
func (*VaultAdapter) LookupKeys ¶
func (ss *VaultAdapter) LookupKeys(keyPath string) ([]string, error)
Get a list of keys that exsist in Vault at the path specified by keyPath. This function prepends the basePath. Retries are implemented for token renewal.
func (*VaultAdapter) Store ¶
func (ss *VaultAdapter) Store(key string, value interface{}) error
Write a struct to Vault at the location specified by key. This function prepends the basePath. Retries are implemented for token renewal.
func (*VaultAdapter) StoreWithData ¶ added in v1.13.0
func (ss *VaultAdapter) StoreWithData(key string, value interface{}, output interface{}) error
Write a struct to Vault at the location specified by key and return the response. This function prepends the basePath. Retries are implemented for token renewal. Note: Unlike Lookup(), this returns the entire response body. Not just secretValues.Data.
type VaultApi ¶
type VaultApi interface {
Read(path string) (*api.Secret, error)
Write(path string, data map[string]interface{}) (*api.Secret, error)
Delete(path string) (*api.Secret, error)
List(path string) (*api.Secret, error)
SetToken(t string)
}
///////////////////////////////////////////////////////////////////////////// Vault API interface - This interface wraps only a subset of functions for api.Client so as to reduce the amount of functions that need to be mocked for unit testing. /////////////////////////////////////////////////////////////////////////////