awsauth

package
v0.33.1 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2025 License: Apache-2.0 Imports: 23 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AWSAPIClient

type AWSAPIClient interface {
	LoadDefaultConfig(ctx context.Context, options ...LoadOptionsFunc) (aws.Config, error)
	NewStaticCredentialsProvider(key, secret, session string) aws.CredentialsProvider
	NewSTSClientFromConfig(cfg aws.Config) stscreds.AssumeRoleAPIClient
	NewAssumeRoleProvider(client stscreds.AssumeRoleAPIClient, roleARN string, optFns ...func(*stscreds.AssumeRoleOptions)) aws.CredentialsProvider
	NewCredentialsCache(provider aws.CredentialsProvider, optFns ...func(options *aws.CredentialsCacheOptions)) aws.CredentialsProvider
	NewEC2RoleCreds() aws.CredentialsProvider
}

AWSAPIClient isolates most of our interactions with the AWS SDK to make it easier to mock in tests

type AuthType

type AuthType string

AuthType enumerates the kinds of authentication that are supported

var (
	AuthTypeDefault           AuthType = "default"
	AuthTypeSharedCreds       AuthType = "credentials"
	AuthTypeKeys              AuthType = "keys"
	AuthTypeEC2IAMRole        AuthType = "ec2_iam_role"
	AuthTypeGrafanaAssumeRole AuthType = "grafana_assume_role"
	AuthTypeUnknown           AuthType = "unknown"
	AuthTypeMissing           AuthType = ""
)

type ConfigProvider

type ConfigProvider interface {
	GetConfig(context.Context, Settings) (aws.Config, error)
}

func NewConfigProvider

func NewConfigProvider() ConfigProvider

func NewFakeConfigProvider

func NewFakeConfigProvider(shouldFail bool) ConfigProvider

NewFakeConfigProvider returns a basic mock satisfying AWSConfigProvider. If shouldFail is true, the GetConfig method will fail. Otherwise it will return a basic config with static credentials

type LoadOptionsFunc

type LoadOptionsFunc = func(*config.LoadOptions) error

type Settings

type Settings struct {
	AuthType AuthType
	// deprecated: use AuthType instead
	LegacyAuthType     awsds.AuthType
	AccessKey          string
	SecretKey          string
	Region             string
	CredentialsPath    string
	CredentialsProfile string
	AssumeRoleARN      string
	Endpoint           string
	ExternalID         string
	UserAgent          string
	HTTPClient         *http.Client
	ProxyOptions       *proxy.Options
}

Settings carries configuration for authenticating with AWS

func (Settings) BaseOptions

func (s Settings) BaseOptions() []LoadOptionsFunc

func (Settings) GetAuthType

func (s Settings) GetAuthType() AuthType

func (Settings) Hash

func (s Settings) Hash() uint64

Hash returns a value suitable for caching the config associated with these settings

func (Settings) WithAssumeRole

func (s Settings) WithAssumeRole(cfg aws.Config, client AWSAPIClient) LoadOptionsFunc

func (Settings) WithEC2RoleCredentials

func (s Settings) WithEC2RoleCredentials(client AWSAPIClient) LoadOptionsFunc

func (Settings) WithEndpoint

func (s Settings) WithEndpoint() LoadOptionsFunc

func (Settings) WithHTTPClient

func (s Settings) WithHTTPClient() LoadOptionsFunc

func (Settings) WithRegion

func (s Settings) WithRegion() LoadOptionsFunc

func (Settings) WithSharedCredentials

func (s Settings) WithSharedCredentials() LoadOptionsFunc

WithSharedCredentials returns a LoadOptionsFunc to initialize config from a credentials file

func (Settings) WithStaticCredentials

func (s Settings) WithStaticCredentials(client AWSAPIClient) LoadOptionsFunc

func (Settings) WithUserAgent

func (s Settings) WithUserAgent() LoadOptionsFunc

WithUserAgent adds info to the UserAgent header of API requests. Adapted from grafana-aws-sdk/pkg/awsds/utils.go

Jump to

Keyboard shortcuts

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