credentials

package
v0.0.0-...-8f9822b Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2019 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const EnvProviderName = "EnvProvider"
View Source
const SharedCredsProviderName = "SharedCredentialsProvider"

Variables

View Source
var (
	ErrUsernameNotFound  = errors.New("ATLAS_USERNAME not found in environment")
	ErrAccessKeyNotFound = errors.New("ATLAS_ACCESS_KEY not found in environment")
)
View Source
var (
	ErrNoValidProvidersFoundInChain = errors.New(`no valid providers in chain`)
)
View Source
var (
	ErrSharedCredentialsHomeNotFound = errors.New("user home directory not found.")
)

Functions

func SharedCredentialsFilename

func SharedCredentialsFilename() string

SharedCredentialsFilename returns the SDK's default file path for the shared credentials file.

func UserHomeDir

func UserHomeDir() string

UserHomeDir returns the home directory for the user the process is running under.

Types

type ChainProvider

type ChainProvider struct {
	Providers []Provider

	VerboseErrors bool
	// contains filtered or unexported fields
}

A ChainProvider will search for a provider which returns credentials.

func (*ChainProvider) IsExpired

func (c *ChainProvider) IsExpired() bool

IsExpired will returned the expired state of the currently cached provider if there is one.

func (*ChainProvider) Retrieve

func (c *ChainProvider) Retrieve() (Value, error)

Retrieve returns the credentials value or error if no provider returned without error.

type Credentials

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

A Credentials provides synchronous safe retrieval of credentials Value.

func NewChainCredentials

func NewChainCredentials(providers []Provider) *Credentials

NewChainCredentials returns a pointer to a new Credentials object wrapping a chain of providers.

func NewCredentials

func NewCredentials(provider Provider) *Credentials

NewCredentials returns a pointer to a new Credentials with the provider set.

func NewEnvCredentials

func NewEnvCredentials() *Credentials

NewEnvCredentials returns a pointer to a new Credentials object wrapping the environment variable provider.

func NewSharedCredentials

func NewSharedCredentials(filename, profile string) *Credentials

NewSharedCredentials returns a pointer to a new Credentials object wrapping the Profile file provider.

func (*Credentials) Expire

func (c *Credentials) Expire()

Expire expires the credentials and forces them to be retrieved on the next call to Get().

func (*Credentials) Get

func (c *Credentials) Get() (Value, error)

Get returns the credentials value, or error if the credentials Value failed to be retrieved.

func (*Credentials) IsExpired

func (c *Credentials) IsExpired() bool

IsExpired returns if the credentials are no longer valid, and need to be retrieved.

type EnvProvider

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

A EnvProvider retrieves credentials from the environment variables of the running process. Environment credentials never expire.

func (*EnvProvider) IsExpired

func (e *EnvProvider) IsExpired() bool

IsExpired returns if the credentials have been retrieved.

func (*EnvProvider) Retrieve

func (e *EnvProvider) Retrieve() (Value, error)

Retrieve retrieves the keys from the environment.

type ErrorProvider

type ErrorProvider struct {
	Err          error
	ProviderName string
}

An ErrorProvider is a stub credentials provider that always returns an error.

func (ErrorProvider) IsExpired

func (p ErrorProvider) IsExpired() bool

IsExpired will always return not expired.

func (ErrorProvider) Retrieve

func (p ErrorProvider) Retrieve() (Value, error)

Retrieve will always return the error that the ErrorProvider was created with.

type Expiry

type Expiry struct {
	CurrentTime func() time.Time
	// contains filtered or unexported fields
}

A Expiry provides shared expiration logic to be used by credentials providers to implement expiry functionality.

func (*Expiry) IsExpired

func (e *Expiry) IsExpired() bool

IsExpired returns if the credentials are expired.

func (*Expiry) SetExpiration

func (e *Expiry) SetExpiration(expiration time.Time, window time.Duration)

SetExpiration sets the expiration IsExpired will check when called.

type Provider

type Provider interface {
	Retrieve() (Value, error)
	IsExpired() bool
}

A Provider is the interface for any component which will provide credentials Value.

type SharedCredentialsProvider

type SharedCredentialsProvider struct {
	Filename string
	Profile  string
	// contains filtered or unexported fields
}

A SharedCredentialsProvider retrieves credentials from the current user's home directory, and keeps track if those credentials are expired.

Profile ini file example: $HOME/.atlas/credentials

func (*SharedCredentialsProvider) IsExpired

func (p *SharedCredentialsProvider) IsExpired() bool

IsExpired returns if the shared credentials have expired.

func (*SharedCredentialsProvider) Retrieve

func (p *SharedCredentialsProvider) Retrieve() (Value, error)

Retrieve reads and extracts the shared credentials from the current users home directory.

type Value

type Value struct {
	Username     string
	AccessKey    string
	ProviderName string
}

A Value is the credentials value for individual credential fields.

Jump to

Keyboard shortcuts

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