Documentation ¶
Overview ¶
Package adapters provides functions and structs for interacting with Vault for storing user secrets.
Index ¶
- func CreateResponseCE(source string, eventType string, obj interface{}) []byte
- type EventOut
- func (e EventOut) EventCredentialAddError(response service.CredentialCreateResponse)
- func (e EventOut) EventCredentialAdded(response service.CredentialCreateResponse)
- func (e EventOut) EventCredentialDeleteError(response service.CredentialDeleteResponse)
- func (e EventOut) EventCredentialDeleted(response service.CredentialDeleteResponse)
- func (e EventOut) EventCredentialUpdateError(response service.CredentialUpdateResponse)
- func (e EventOut) EventCredentialUpdated(response service.CredentialUpdateResponse)
- type PostgresStorage
- func (ps *PostgresStorage) Close()
- func (ps *PostgresStorage) Create(cred service.CredentialModel) error
- func (ps *PostgresStorage) Delete(cred service.CredentialModel) error
- func (ps *PostgresStorage) Get(cred service.CredentialModel) (service.CredentialModel, error)
- func (ps *PostgresStorage) GetAndDelete(cred service.CredentialModel) (*service.CredentialModel, error)
- func (ps *PostgresStorage) Import(cred service.CredentialModel) error
- func (ps *PostgresStorage) Init(conf types.Config) error
- func (ps *PostgresStorage) InitDatabase() error
- func (ps *PostgresStorage) List(queryData types.ListQueryData) ([]service.CredentialModel, error)
- func (ps *PostgresStorage) MigrateSchemaVersionFrom1To2(ctx context.Context) error
- func (ps *PostgresStorage) Update(credUpdate types.CredUpdate) error
- type QueryAdapter
- type StanEventAdapter
- type VaultCredentialStorage
- func (storage VaultCredentialStorage) Create(credModel service.CredentialModel) error
- func (storage VaultCredentialStorage) Delete(credModel service.CredentialModel) error
- func (storage VaultCredentialStorage) Get(credModel service.CredentialModel) (service.CredentialModel, error)
- func (storage VaultCredentialStorage) GetAndDelete(d service.CredentialModel) (*service.CredentialModel, error)
- func (storage VaultCredentialStorage) Init(c types.Config) error
- func (storage VaultCredentialStorage) List(filter types.ListQueryData) ([]service.CredentialModel, error)
- func (storage VaultCredentialStorage) Update(credUpdate types.CredUpdate) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateResponseCE ¶
CreateResponseCE creates a response cloudevents
Types ¶
type EventOut ¶
type EventOut struct {
// contains filtered or unexported fields
}
EventOut ...
func (EventOut) EventCredentialAddError ¶
func (e EventOut) EventCredentialAddError(response service.CredentialCreateResponse)
EventCredentialAddError ...
func (EventOut) EventCredentialAdded ¶
func (e EventOut) EventCredentialAdded(response service.CredentialCreateResponse)
EventCredentialAdded ...
func (EventOut) EventCredentialDeleteError ¶
func (e EventOut) EventCredentialDeleteError(response service.CredentialDeleteResponse)
EventCredentialDeleteError ...
func (EventOut) EventCredentialDeleted ¶
func (e EventOut) EventCredentialDeleted(response service.CredentialDeleteResponse)
EventCredentialDeleted ...
func (EventOut) EventCredentialUpdateError ¶
func (e EventOut) EventCredentialUpdateError(response service.CredentialUpdateResponse)
EventCredentialUpdateError ...
func (EventOut) EventCredentialUpdated ¶
func (e EventOut) EventCredentialUpdated(response service.CredentialUpdateResponse)
EventCredentialUpdated ...
type PostgresStorage ¶
type PostgresStorage struct {
// contains filtered or unexported fields
}
PostgresStorage is a persistent storage for credential based on postgres.
func NewPostgresStorage ¶
func NewPostgresStorage(src ports.TimeSrc) *PostgresStorage
NewPostgresStorage ...
func (*PostgresStorage) Create ¶
func (ps *PostgresStorage) Create(cred service.CredentialModel) error
Create ...
func (*PostgresStorage) Delete ¶
func (ps *PostgresStorage) Delete(cred service.CredentialModel) error
Delete ...
func (*PostgresStorage) Get ¶
func (ps *PostgresStorage) Get(cred service.CredentialModel) (service.CredentialModel, error)
Get ...
func (*PostgresStorage) GetAndDelete ¶
func (ps *PostgresStorage) GetAndDelete(cred service.CredentialModel) (*service.CredentialModel, error)
GetAndDelete delete a credential by ID and username, returns the current credential data stored in DB. Will return nil if credential is not found.
func (*PostgresStorage) Import ¶
func (ps *PostgresStorage) Import(cred service.CredentialModel) error
Import imports a credential, timestamps (creation, update) are not overwritten.
func (*PostgresStorage) Init ¶
func (ps *PostgresStorage) Init(conf types.Config) error
Init initialize database connection from config
func (*PostgresStorage) InitDatabase ¶
func (ps *PostgresStorage) InitDatabase() error
InitDatabase ...
func (*PostgresStorage) List ¶
func (ps *PostgresStorage) List(queryData types.ListQueryData) ([]service.CredentialModel, error)
List lists all credentials for a user. Value field is left as "REDACTED".
func (*PostgresStorage) MigrateSchemaVersionFrom1To2 ¶
func (ps *PostgresStorage) MigrateSchemaVersionFrom1To2(ctx context.Context) error
MigrateSchemaVersionFrom1To2 encrypt the cred value using pgcrypto extension.
func (*PostgresStorage) Update ¶
func (ps *PostgresStorage) Update(credUpdate types.CredUpdate) error
Update updates certain fields of a credential.
type QueryAdapter ¶
type QueryAdapter struct {
// contains filtered or unexported fields
}
QueryAdapter is an example of a Driver Adapter.
func (*QueryAdapter) Init ¶
func (q *QueryAdapter) Init(c types.Config) error
Init is the init function required per the Port interface
func (*QueryAdapter) SetHandlers ¶
func (q *QueryAdapter) SetHandlers(handlers ports.IncomingQueryHandlers)
SetHandlers ...
type StanEventAdapter ¶
type StanEventAdapter struct {
// contains filtered or unexported fields
}
StanEventAdapter ...
func (*StanEventAdapter) SetHandlers ¶
func (sa *StanEventAdapter) SetHandlers(handlers ports.IncomingEventHandlers)
SetHandlers ...
type VaultCredentialStorage ¶
type VaultCredentialStorage struct {
// contains filtered or unexported fields
}
VaultCredentialStorage is a storage backend based on Vault's KV (version 1) secret engine
func NewVaultCredentialStorage ¶
func NewVaultCredentialStorage(cfg types.Config, timeSrc ports.TimeSrc) (*VaultCredentialStorage, error)
NewVaultCredentialStorage creates a new Vault client for interacting with the Vault server
func (VaultCredentialStorage) Create ¶
func (storage VaultCredentialStorage) Create(credModel service.CredentialModel) error
Create creates a credential. Note: this will overwrite the credential with the same ID and username(owner).
func (VaultCredentialStorage) Delete ¶
func (storage VaultCredentialStorage) Delete(credModel service.CredentialModel) error
Delete deletes a credential by ID and username(owner).
func (VaultCredentialStorage) Get ¶
func (storage VaultCredentialStorage) Get(credModel service.CredentialModel) (service.CredentialModel, error)
Get fetches a credential based on ID and username(owner).
func (VaultCredentialStorage) GetAndDelete ¶
func (storage VaultCredentialStorage) GetAndDelete(d service.CredentialModel) (*service.CredentialModel, error)
GetAndDelete ...
func (VaultCredentialStorage) Init ¶
func (storage VaultCredentialStorage) Init(c types.Config) error
Init do nothing, just implement interface PersistentStoragePort
func (VaultCredentialStorage) List ¶
func (storage VaultCredentialStorage) List(filter types.ListQueryData) ([]service.CredentialModel, error)
List returns a list of all credential owned by a user. Note: invalid credential(credential that missing required field) are discarded. TODO consider make concurrent calls for fetching list items
func (VaultCredentialStorage) Update ¶
func (storage VaultCredentialStorage) Update(credUpdate types.CredUpdate) error
Update ... TODO This function should likely be looked at in the future, as of right now it will just overwrite any existing secret with the same key name, but it could be troublesome under certain update sequences.