awsauth

package
v1.3.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const EmptySha256Hash = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"

Variables

This section is empty.

Functions

func NewSigV4Middleware added in v1.0.0

func NewSigV4Middleware(signerOpts ...func(signer *v4.SignerOptions)) httpclient.Middleware

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 Clock added in v1.0.0

type Clock interface {
	Now() time.Time
}

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
	SessionToken       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, sessionDuration *time.Duration) LoadOptionsFunc

func (Settings) WithEC2RoleCredentials

func (s Settings) WithEC2RoleCredentials(client AWSAPIClient) LoadOptionsFunc

func (Settings) WithEndpoint

func (s Settings) WithEndpoint() LoadOptionsFunc

func (Settings) WithGrafanaAssumeRole added in v0.36.0

func (s Settings) WithGrafanaAssumeRole(ctx context.Context, client AWSAPIClient) LoadOptionsFunc

WithGrafanaAssumeRole returns a LoadOptionsFunc to initialize config for Grafana Assume Role

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

type SignerMiddleware added in v1.0.0

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

func (SignerMiddleware) CreateMiddleware added in v1.0.0

func (s SignerMiddleware) CreateMiddleware(opts httpclient.Options, next http.RoundTripper) http.RoundTripper

func (SignerMiddleware) MiddlewareName added in v1.0.0

func (s SignerMiddleware) MiddlewareName() string

type SignerRoundTripper added in v1.0.0

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

func NewSignerRoundTripper added in v1.0.0

func NewSignerRoundTripper(opts httpclient.Options, next http.RoundTripper, signer v4.HTTPSigner) SignerRoundTripper

func (SignerRoundTripper) RoundTrip added in v1.0.0

func (s SignerRoundTripper) RoundTrip(req *http.Request) (resp *http.Response, e error)

func (SignerRoundTripper) SignHTTP added in v1.0.0

func (s SignerRoundTripper) SignHTTP(ctx context.Context, req *http.Request, credentials aws.Credentials) error

Jump to

Keyboard shortcuts

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