credentials

package
v0.0.0-...-6698953 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ProviderFactories = map[ProviderType]ProviderFactory{
	LocalProviderType:         LocalFactory,
	AzureKeyVaultProviderType: AzureKeyVaultFactory,
}

ProviderFactories contains the ProviderFactory for the implemented Provider s.

Functions

This section is empty.

Types

type AzureKeyVault

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

AzureKeyVault is a collection of credentials stored in an Azure Key Vault (https://azure.microsoft.com/en-us/services/key-vault/#product-overview) instance.

func NewAzureKeyVault

func NewAzureKeyVault(credsMapping map[string]string) (*AzureKeyVault, error)

NewAzureKeyVault returns a new instance of AzureKeyVault. It requires the following env variables to be set: AZURE_TENANT_ID, AZURE_CLIENT_ID, AZURE_CLIENT_CERTIFICATE_PATH (or, in alternative, AZURE_CLIENT_SECRET), AZURE_KEY_VAULT_URI.

func (AzureKeyVault) GetCredentials

func (akv AzureKeyVault) GetCredentials(credID string) (*Credentials, error)

GetCredentials returns the credentials, stored in @akv, identified by @credID. If @credID is mapped to a different Azure Key Vault secret ID in akv.credsMapping, the function will use this last one to retrieve the credentials.

func (AzureKeyVault) Type

func (akv AzureKeyVault) Type() ProviderType

Type returns the ProviderType of AzureKeyVault.

type Credentials

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

Credentials contains the credentials to access a resource.

func NewCredentials

func NewCredentials(username, password, connectionString string) *Credentials

NewCredentials returns a new instance of Credentials containing the passed parameters.

func (Credentials) ConnectionString

func (cred Credentials) ConnectionString() string

ConnectionString returns the connection string linked to a Credentials instance. If no connection string is linked to the credentials, an empty string is returned.

func (Credentials) Password

func (cred Credentials) Password() string

Password returns the password linked to a Credentials instance. If no password is linked to the credentials, an empty string is returned.

func (Credentials) Username

func (cred Credentials) Username() string

Username returns the username linked to a Credentials instance. If no username is linked to the credentials, an empty string is returned.

type Local

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

Local is a collection of locally stored credentials.

func NewLocal

func NewLocal(credentials map[string]*Credentials) *Local

NewLocal returns a new instance of Local initialized with @credentials.

func (Local) GetCredentials

func (local Local) GetCredentials(credID string) (cred *Credentials, err error)

GetCredentials returns the credentials, stored in @local, identified by @credID. If no credentials are stored under the provided @credID, it returns an error.

func (*Local) SetCredentials

func (local *Local) SetCredentials(credID string, cred *Credentials)

SetCredentials stores @cred in @local under @credID. It silently overwrites any credentials previously stored under @credID.

func (Local) Type

func (local Local) Type() ProviderType

Type returns the ProviderType of Local.

type Provider

type Provider interface {
	// Type returns the Provider type.
	Type() ProviderType
	// GetCredentials returns the Credentials identified by @credID.
	GetCredentials(credID string) (*Credentials, error)
}

Provider is the interface that all credentials providers must implement.

func AzureKeyVaultFactory

func AzureKeyVaultFactory(args ...interface{}) (Provider, error)

AzureKeyVaultFactory is the ProviderFactory for AzureKeyVault. It accepts the same arguments as AzureKeyVault.

func LocalFactory

func LocalFactory(args ...interface{}) (Provider, error)

LocalFactory is the ProviderFactory for Local. It accepts the same arguments as NewLocal.

type ProviderFactory

type ProviderFactory func(...interface{}) (Provider, error)

ProviderFactory is a function that instantiates a Provider.

type ProviderType

type ProviderType string

ProviderType is the Provider type.

const AzureKeyVaultProviderType ProviderType = "azure-key-vault"

AzureKeyVaultProviderType is the type of AzureKeyVault.

const LocalProviderType ProviderType = "local"

LocalProviderType is the type of Local.

Jump to

Keyboard shortcuts

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