credentials

package
v0.0.0-...-3c45f7e Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package credentials implements credential management for signing requests.

Credentials consist of an access key ID, a secret access key as well as an optional session token.

This package implements providers for retrieving credentials from different sources.

Index

Constants

View Source
const StaticProviderName = "StaticProvider"

StaticProviderName represents the name of the static credentials provider

Variables

View Source
var (
	// ErrStaticCredentialsEmpty indicates missing credentials required for a static provider
	ErrStaticCredentialsEmpty = errors.New("static credentials are empty")
)

Functions

This section is empty.

Types

type Credentials

type Credentials struct {
	// AWS Access Key ID
	AccessKeyID string
	// AWS Secret Access Key
	SecretAccessKey string
	// AWS Session Token
	SessionToken string
	// Name of provider used to retrieve credentials
	ProviderName string
}

Credentials represents a set of credentials consisting of an access key ID and its corresponding secret as well as an optional session token.

func (Credentials) DeriveSigningKey

func (c Credentials) DeriveSigningKey(t time.Time, region string, service string) []byte

DeriveSigningKey derives a HMAC signing key from the credentials in accordance with the AWS Signature Version 4 specification using the signing time as well as the region and service of the request.

type Provider

type Provider interface {
	// Retrieve returns a set of credentials or an error if retrieval failed.
	Retrieve() (Credentials, error)
	// IsExpired indicates whether the credentials managed by the provider have expired.
	IsExpired() bool
}

Provider presents an interface for retrieving credentials.

type StaticProvider

type StaticProvider struct {
	Credentials
}

StaticProvider implements a provider using a static set of credentials, returning the defined access key and optional session token. No expiry or renewal will be managed by the provider.

func NewStaticProvider

func NewStaticProvider(id string, secret string, token string) *StaticProvider

NewStaticProvider returns a new static credentials provider using the given set of credentials.

func (*StaticProvider) IsExpired

func (s *StaticProvider) IsExpired() bool

IsExpired returns whether the stored credentials are expired. In the case of a static provider, this will always return false since expiry is not managed by the provider.

func (*StaticProvider) Retrieve

func (s *StaticProvider) Retrieve() (Credentials, error)

Retrieve verifies the required static credentials are available and returns them.

Jump to

Keyboard shortcuts

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