credentials

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2019 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AWSS3Source

type AWSS3Source struct {
	Bucket string
	Key    string
}

AWSS3Source represents s3 objects containing credentials

func (*AWSS3Source) Credentials

func (source *AWSS3Source) Credentials() ([]Credentials, error)

Credentials extracts credentials from the source

func (*AWSS3Source) Type

func (source *AWSS3Source) Type() string

Type returns the type of the source

func (*AWSS3Source) ValidateConfiguration

func (source *AWSS3Source) ValidateConfiguration() bool

ValidateConfiguration verifies that the source's attributes are valid

type AWSSecretsManagerSource

type AWSSecretsManagerSource struct {
	SecretPrefix string `mapstructure:"secret_prefix"`
	SecretID     string `mapstructure:"secret_id"`
}

AWSSecretsManagerSource represents AWS SecretsManager secrets containing credentials

func (*AWSSecretsManagerSource) Credentials

func (source *AWSSecretsManagerSource) Credentials() ([]Credentials, error)

Credentials extracts credentials from the source

func (*AWSSecretsManagerSource) Type

func (source *AWSSecretsManagerSource) Type() string

Type returns the type of the source

func (*AWSSecretsManagerSource) ValidateConfiguration

func (source *AWSSecretsManagerSource) ValidateConfiguration() bool

ValidateConfiguration verifies that the source's attributes are valid

type AmazonWebServicesCredentials

type AmazonWebServicesCredentials struct {
	Base            `mapstructure:",squash"`
	AccessKey       string `mapstructure:"access_key"`
	SecretKey       string `mapstructure:"secret_key"`
	RoleARN         string `mapstructure:"role_arn"`
	MFASerialNumber string `mapstructure:"mfa_serial"`
}

AmazonWebServicesCredentials represents an access key id and a secret access key from AWS. A role to assume can also be defined

func NewAmazonWebServicesCredentials

func NewAmazonWebServicesCredentials() *AmazonWebServicesCredentials

NewAmazonWebServicesCredentials instantiates an AmazonWebServicesCredentials struct

func (*AmazonWebServicesCredentials) ToString

func (cred *AmazonWebServicesCredentials) ToString(showSensitive bool) string

ToString prints out the content of a AmazonWebServicesCredentials struct. If showSensitive is true, the secret access key will be shown

func (*AmazonWebServicesCredentials) Validate

func (cred *AmazonWebServicesCredentials) Validate() bool

Validate verifies that the credentials is valid. A AmazonWebServicesCredentials must define an access key and a secret access key

type Base

type Base struct {
	ID          string
	Description string
	NoSync      bool              `mapstructure:"no_sync"`
	TargetName  string            `mapstructure:"target"`
	TargetTags  targetTagsMatcher `mapstructure:"target_tags"`

	// Field set by constructor
	CredType string

	// For multi-value fields. Such as SSM
	Value string
}

Base defines that fields that are common to all types of credentials

func (*Base) BaseToString

func (credBase *Base) BaseToString() string

BaseToString prints out the credentials fields common to all types of credentials

func (*Base) BaseValidate

func (credBase *Base) BaseValidate() bool

BaseValidate verifies that the credentials fields common to all types of credentials contain valid values

func (*Base) GetDescriptionOrID

func (credBase *Base) GetDescriptionOrID() string

GetDescriptionOrID returns the description if it set, otherwise it returns the ID

func (*Base) GetID

func (credBase *Base) GetID() string

GetID returns a credentials' ID

func (*Base) ShouldSync

func (credBase *Base) ShouldSync(targetName string, targetTags map[string]string) bool

ShouldSync returns, given a target's name and tags, if a credentials should be synced to that target This is based on various credentials attributes such as the TargetTags DoMatch and DontMatch attributes

type Credentials

type Credentials interface {
	BaseValidate() bool
	GetID() string
	ShouldSync(targetName string, targetTags map[string]string) bool
	ToString(bool) string
	Validate() bool
}

Credentials defines the methods that can be called by all types of credentials

func ParseCredentials

func ParseCredentials(credentialsMaps []map[string]interface{}) ([]Credentials, error)

ParseCredentials transforms a list of maps into a list of Credentials The credentials type is determined by the `type` attribute

func ParseSingleCredentials

func ParseSingleCredentials(credentialsMap map[string]interface{}) (Credentials, error)

ParseSingleCredentials transforms a map into a Credentials struct The credentials type is determined by the `type` attribute

type LocalSource

type LocalSource struct {
	File string
}

LocalSource represents local files containing credentials

func (*LocalSource) Credentials

func (source *LocalSource) Credentials() ([]Credentials, error)

Credentials extracts credentials from the source

func (*LocalSource) Type

func (source *LocalSource) Type() string

Type returns the type of the source

func (*LocalSource) ValidateConfiguration

func (source *LocalSource) ValidateConfiguration() bool

ValidateConfiguration verifies that the source's attributes are valid

type SSHCredentials

type SSHCredentials struct {
	Base       `mapstructure:",squash"`
	Username   string
	Passphrase string
	PrivateKey string `mapstructure:"private_key"`
}

SSHCredentials represents credentials composed of a private key, username and passphrase

func NewSSHCredentials

func NewSSHCredentials() *SSHCredentials

NewSSHCredentials instantiates a SSHCredentials struct

func (*SSHCredentials) ToString

func (cred *SSHCredentials) ToString(showSensitive bool) string

ToString prints out the content of a UsernamePasswordCredentials struct. If showSensitive is true, the passphrase will be shown

func (*SSHCredentials) Validate

func (cred *SSHCredentials) Validate() bool

Validate verifies that the credentials is valid. A SSHCredentials must have a private key, the username and passphrase are optional

type SecretTextCredentials

type SecretTextCredentials struct {
	Base   `mapstructure:",squash"`
	Secret string
}

SecretTextCredentials represents credentials composed of a single string value

func NewSecretText

func NewSecretText() *SecretTextCredentials

NewSecretText instantiates a SecretTextCredentials struct

func (*SecretTextCredentials) ToString

func (cred *SecretTextCredentials) ToString(showSensitive bool) string

ToString prints out the content of a SecretTextCredentials struct. If showSensitive is true, the secret text will be shown

func (*SecretTextCredentials) Validate

func (cred *SecretTextCredentials) Validate() bool

Validate verifies that the credentials is valid. A SecretTextCredentials is always considered valid, as empty values are accepted.

type Source

type Source interface {
	Credentials() ([]Credentials, error)
	Type() string
	ValidateConfiguration() bool
}

Source represents a location to fetch credentials

type SourcesConfiguration

type SourcesConfiguration struct {
	AWSS3Sources            []*AWSS3Source             `mapstructure:"aws_s3"`
	AWSSecretsManagerSource []*AWSSecretsManagerSource `mapstructure:"aws_secretsmanager"`
	LocalSources            []*LocalSource             `mapstructure:"local"`
	// contains filtered or unexported fields
}

SourcesConfiguration contains all configured sources

func (*SourcesConfiguration) AllSources

func (sc *SourcesConfiguration) AllSources() []Source

AllSources returns all configured sources in a single list

func (*SourcesConfiguration) Credentials

func (sc *SourcesConfiguration) Credentials() ([]Credentials, error)

Credentials extracts credentials from all configured sources

func (*SourcesConfiguration) ValidateConfiguration

func (sc *SourcesConfiguration) ValidateConfiguration() bool

ValidateConfiguration verifies that all configured sources are correctly configured

type UsernamePasswordCredentials

type UsernamePasswordCredentials struct {
	Base     `mapstructure:",squash"`
	Username string
	Password string
}

UsernamePasswordCredentials represents credentials composed of a username and a password

func NewUsernamePassword

func NewUsernamePassword() *UsernamePasswordCredentials

NewUsernamePassword instantiates a UsernamePasswordCredentials struct

func (*UsernamePasswordCredentials) ToString

func (cred *UsernamePasswordCredentials) ToString(showSensitive bool) string

ToString prints out the content of a UsernamePasswordCredentials struct. If showSensitive is true, the password will be shown

func (*UsernamePasswordCredentials) Validate

func (cred *UsernamePasswordCredentials) Validate() bool

Validate verifies that the credentials is valid. A UsernamePasswordCredentials is always considered valid, as empty values are accepted.

Jump to

Keyboard shortcuts

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