credentials

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package credentials is the framework-owned boundary shared by S3, R2 and SES. Applications can use static settings, the AWS chain or a rotating Provider without importing an SDK. Credentials are never logged or stored in reports.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SettingsConfigSchema

func SettingsConfigSchema() (*config.Schema[Settings], error)

SettingsConfigSchema reuses the shared file/environment/override loader.

Types

type Mode

type Mode string

Mode selects the credential source mode.

const (
	Chain  Mode = "chain"
	Static Mode = "static"
)

type Name

type Name string

Name identifies a named credential provider.

func (Name) Validate

func (n Name) Validate() error

Validate validates the credential provider name.

type Provider

type Provider interface {
	// Retrieve retrieves cloud credentials for the supplied context.
	Retrieve(context.Context) (Value, error)
}

Provider implementations own refresh and must honor cancellation. Retrieve returns an immutable snapshot; callers never retry ambiguous delivery.

type ProviderFunc

type ProviderFunc func(context.Context) (Value, error)

ProviderFunc adapts a function to Provider.

func (ProviderFunc) Retrieve

func (f ProviderFunc) Retrieve(ctx context.Context) (Value, error)

Retrieve calls the provider function after rejecting nil functions, nil contexts, and canceled contexts.

type Settings

type Settings struct {
	Mode                               Mode
	Profile                            string
	AccessKey, SecretKey, SessionToken secret.String
}

Settings selects a reusable source. Chain preserves standard AWS discovery; R2 configuration requires an explicitly selected non-chain source.

func DefaultSettings

func DefaultSettings() Settings

DefaultSettings returns credential settings using the AWS provider chain.

func (Settings) Format

func (Settings) Format(s fmt.State, _ rune)

Format writes a fixed label without exposing credentials.

func (Settings) Validate

func (s Settings) Validate() error

Validate checks the selected credential mode and its static key or profile settings.

type SettingsConfigKeySet

type SettingsConfigKeySet struct {
	// Mode selects mode. Set accepts Mode.
	Mode config.Key[Settings, Mode]
	// Profile selects profile. Set accepts string.
	Profile config.Key[Settings, string]
	// AccessKey selects access_key. Set accepts secret.String.
	AccessKey config.Key[Settings, secret.String]
	// SecretKey selects secret_key. Set accepts secret.String.
	SecretKey config.Key[Settings, secret.String]
	// SessionToken selects session_token. Set accepts secret.String.
	SessionToken config.Key[Settings, secret.String]
}

SettingsConfigKeySet exposes compiler-checked configuration overrides.

func SettingsConfigKeys

func SettingsConfigKeys() SettingsConfigKeySet

SettingsConfigKeys derives keys from the handwritten settings declaration.

type Source

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

Source owns the chain's transport. Prepare is pure; Start loads chain settings at boot. Retrieval/refresh occurs on demand through the existing AWS SDK.

func Prepare

func Prepare(settings Settings) (*Source, error)

Prepare validates settings and creates a credential source that must be started before retrieval.

func (*Source) Close

func (s *Source) Close() error

Close marks the source closed and closes idle transport connections. A nil source is harmless.

func (Source) Format

func (Source) Format(s fmt.State, _ rune)

Format and LogValue keep private chain/static state out of diagnostics.

func (Source) LogValue

func (Source) LogValue() slog.Value

LogValue returns a fixed log label without exposing credentials.

func (*Source) Retrieve

func (s *Source) Retrieve(ctx context.Context) (Value, error)

Retrieve retrieves and validates credentials from an active source; an inactive source returns a closed fault.

func (*Source) Start

func (s *Source) Start(ctx context.Context) error

Start initializes the configured credential source once. A closed source cannot restart.

type Value

type Value struct {
	AccessKey, SecretKey, SessionToken secret.String
	Expires                            time.Time
}

Value supports temporary, rotating credentials and explicit expiration.

func (Value) Format

func (Value) Format(s fmt.State, _ rune)

Format writes a fixed label without exposing credentials.

func (Value) Validate

func (v Value) Validate() error

Validate checks that the access key and secret key are present.

Jump to

Keyboard shortcuts

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