adapters

package
v0.0.0-...-32e231b Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2024 License: BSD-3-Clause Imports: 21 Imported by: 0

Documentation

Overview

Package adapters provides functions and structs for interacting with Vault for storing user secrets.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateResponseCE

func CreateResponseCE(source string, eventType string, obj interface{}) []byte

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) Close

func (ps *PostgresStorage) Close()

Close ...

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

Get ...

func (*PostgresStorage) GetAndDelete

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

List lists all credentials for a user. Value field is left as "REDACTED".

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 NewNATSQueryAdapter

func NewNATSQueryAdapter() *QueryAdapter

NewNATSQueryAdapter ...

func (*QueryAdapter) Close

func (q *QueryAdapter) Close() error

Close closes the connection

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 ...

func (*QueryAdapter) Start

func (q *QueryAdapter) Start(ctx context.Context, wg *sync.WaitGroup) error

Start tells the adapter to start listening for queries. The adapter will stop listening if context.Context is canceled. sync.WaitGroup.Done() will be called when adapter stopped listening.

type StanEventAdapter

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

StanEventAdapter ...

func (*StanEventAdapter) Close

func (sa *StanEventAdapter) Close() error

Close ...

func (*StanEventAdapter) Init

func (sa *StanEventAdapter) Init(conf types.Config) error

Init ...

func (*StanEventAdapter) SetHandlers

func (sa *StanEventAdapter) SetHandlers(handlers ports.IncomingEventHandlers)

SetHandlers ...

func (*StanEventAdapter) Start

func (sa *StanEventAdapter) Start(ctx context.Context, wg *sync.WaitGroup) error

Start ...

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

Get fetches a credential based on ID and username(owner).

func (VaultCredentialStorage) GetAndDelete

GetAndDelete ...

func (VaultCredentialStorage) Init

func (storage VaultCredentialStorage) Init(c types.Config) error

Init do nothing, just implement interface PersistentStoragePort

func (VaultCredentialStorage) List

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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