types

package
v1.197.0-test.7 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2025 License: Apache-2.0 Imports: 14 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package types is a generated GoMock package.

Index

Constants

View Source
const (
	// AWS provider kinds.
	ProviderKindAWSIAMIdentityCenter = "aws/iam-identity-center"
	ProviderKindAWSSAML              = "aws/saml"
	ProviderKindAWSUser              = "aws/user"
	ProviderKindAWSAssumeRole        = "aws/assume-role"
	ProviderKindAWSPermissionSet     = "aws/permission-set"

	// Azure provider kinds.
	ProviderKindAzureOIDC = "azure/oidc"

	// GCP provider kinds.
	ProviderKindGCPOIDC = "gcp/oidc"

	// GitHub provider kinds.
	ProviderKindGitHubOIDC = "github/oidc"
)

Provider kind constants for identifying provider types.

View Source
const (
	CredentialStoreTypeSystemKeyring = "system-keyring"
	CredentialStoreTypeNoop          = "noop"
	CredentialStoreTypeMemory        = "memory"
	CredentialStoreTypeFile          = "file"
)

Credential store type constants.

Variables

This section is empty.

Functions

This section is empty.

Types

type AWSCredentials

type AWSCredentials struct {
	AccessKeyID     string `json:"access_key_id,omitempty"`
	SecretAccessKey string `json:"secret_access_key,omitempty"`
	SessionToken    string `json:"session_token,omitempty"`
	Region          string `json:"region,omitempty"`
	Expiration      string `json:"expiration,omitempty"`
	MfaArn          string `json:"mfa_arn,omitempty"`
	SessionDuration string `json:"session_duration,omitempty"` // Duration string (e.g., "12h", "24h")
}

AWSCredentials defines AWS-specific credential fields.

func (*AWSCredentials) BuildWhoamiInfo

func (c *AWSCredentials) BuildWhoamiInfo(info *WhoamiInfo)

BuildWhoamiInfo implements ICredentials for AWSCredentials.

func (*AWSCredentials) GetExpiration

func (c *AWSCredentials) GetExpiration() (*time.Time, error)

GetExpiration implements ICredentials for AWSCredentials.

func (*AWSCredentials) IsExpired

func (c *AWSCredentials) IsExpired() bool

IsExpired returns true if the credentials are expired. This implements the ICredentials interface.

func (*AWSCredentials) Validate added in v1.196.0

func (c *AWSCredentials) Validate(ctx context.Context) (*ValidationInfo, error)

Validate validates AWS credentials by calling STS GetCallerIdentity. Returns validation info including ARN, account, and expiration.

type AuthManager

type AuthManager interface {
	// GetCachedCredentials retrieves valid cached credentials for the specified identity.
	// This is a passive check that does not trigger any authentication flows.
	// It checks:
	//   1. Keyring for cached credentials
	//   2. Identity-managed storage (AWS files, etc.)
	// Returns error if credentials are not found, expired, or invalid.
	// Use this when you want to use existing credentials without triggering authentication.
	GetCachedCredentials(ctx context.Context, identityName string) (*WhoamiInfo, error)

	// Authenticate performs full authentication for the specified identity.
	// This may trigger interactive authentication flows (SSO device prompts, etc.).
	// Use this when you want to force fresh authentication (e.g., `auth login` command).
	Authenticate(ctx context.Context, identityName string) (*WhoamiInfo, error)

	// Whoami returns information about the specified identity's credentials.
	// First checks for cached credentials, then falls back to chain authentication
	// (using cached provider credentials to derive identity credentials).
	// This does NOT trigger interactive authentication flows (no SSO prompts).
	// Use this for user-facing "whoami" command and as a fallback check.
	Whoami(ctx context.Context, identityName string) (*WhoamiInfo, error)

	// Validate validates the entire auth configuration.
	Validate() error

	// GetDefaultIdentity returns the name of the default identity, if any.
	//
	// Parameters:
	//   - forceSelect: When true and terminal is interactive, always displays the identity
	//     selector even if a default identity is configured. This allows users to override
	//     the default choice interactively.
	//
	// Returns:
	//   - string: The name of the selected or default identity
	//   - error: An error if no identity is available or selection fails
	//
	// Behavior:
	//   - If forceSelect is true: Displays interactive selector (if terminal supports it)
	//   - If forceSelect is false: Returns configured default identity if available
	//   - If no default and not interactive: Returns error indicating no identity available
	GetDefaultIdentity(forceSelect bool) (string, error)

	// ListIdentities returns all available identity names.
	ListIdentities() []string

	// GetProviderForIdentity returns the root provider name for the given identity.
	// Recursively resolves through identity chains to find the root provider.
	GetProviderForIdentity(identityName string) string

	// GetFilesDisplayPath returns the display path for AWS files for a provider.
	// Returns the configured path if set, otherwise default ~/.aws/atmos.
	GetFilesDisplayPath(providerName string) string

	// GetProviderKindForIdentity returns the provider kind for the given identity.
	GetProviderKindForIdentity(identityName string) (string, error)

	// GetChain returns the most recently constructed authentication chain
	// in the format: [providerName, identity1, identity2, ..., targetIdentity].
	GetChain() []string

	// GetStackInfo returns the current stack info pointer associated with this manager.
	GetStackInfo() *schema.ConfigAndStacksInfo

	// ListProviders returns all available provider names.
	ListProviders() []string

	// GetIdentities returns all available identity configurations.
	GetIdentities() map[string]schema.Identity

	// GetProviders returns all available provider configurations.
	GetProviders() map[string]schema.Provider

	// Logout removes credentials for the specified identity and its authentication chain.
	// Best-effort: continues cleanup even if individual steps fail.
	Logout(ctx context.Context, identityName string) error

	// LogoutProvider removes all credentials for the specified provider.
	// Best-effort: continues cleanup even if individual steps fail.
	LogoutProvider(ctx context.Context, providerName string) error

	// LogoutAll removes all cached credentials for all identities.
	// Best-effort: continues cleanup even if individual steps fail.
	LogoutAll(ctx context.Context) error

	// GetEnvironmentVariables returns the environment variables for an identity
	// without performing authentication or validation.
	// This is useful for commands like `atmos env` that just need to show what
	// environment variables would be set, without requiring valid credentials.
	GetEnvironmentVariables(identityName string) (map[string]string, error)

	// PrepareShellEnvironment prepares environment variables for subprocess execution.
	// Takes current environment list and returns it with auth credentials configured.
	// This calls identity.PrepareEnvironment() internally to configure file-based credentials,
	// credential paths, regions, and clear conflicting variables.
	// The input currentEnv should include any previous transformations (component env, workflow env, etc.).
	// Returns environment variables as a list of "KEY=VALUE" strings ready for subprocess.
	// Use this for all subprocess invocations: Terraform, Helmfile, Packer, workflows, custom commands, auth shell, etc.
	PrepareShellEnvironment(ctx context.Context, identityName string, currentEnv []string) ([]string, error)
}

AuthManager manages the overall authentication process.

type ConsoleAccessProvider added in v1.196.0

type ConsoleAccessProvider interface {
	// GetConsoleURL generates a web console sign-in URL using the provided credentials.
	// Returns the sign-in URL, the duration for which the URL remains valid, and any error encountered.
	GetConsoleURL(ctx context.Context, creds ICredentials, options ConsoleURLOptions) (url string, duration time.Duration, err error)

	// SupportsConsoleAccess returns true if this provider supports web console access.
	SupportsConsoleAccess() bool
}

ConsoleAccessProvider is an optional interface that providers can implement to support web console/browser-based login.

type ConsoleURLOptions added in v1.196.0

type ConsoleURLOptions struct {
	// Destination is the specific console page to navigate to (optional).
	// For AWS: "https://console.aws.amazon.com/s3" or similar.
	// For Azure: "https://portal.azure.com/#blade/...".
	// For GCP: "https://console.cloud.google.com/...".
	Destination string

	// SessionDuration is the requested duration for the console session (how long you stay logged in).
	// Providers may have maximum limits (e.g., AWS: 12 hours).
	// Note: AWS signin tokens themselves have a fixed 15-minute expiration (time to click the link).
	SessionDuration time.Duration

	// Issuer is an optional identifier shown in the console URL (used by AWS).
	Issuer string

	// OpenInBrowser if true, automatically opens the URL in the default browser.
	OpenInBrowser bool
}

ConsoleURLOptions provides configuration for console URL generation.

type CredentialStore

type CredentialStore interface {
	// Store stores credentials for the given alias.
	Store(alias string, creds ICredentials) error

	// Retrieve retrieves credentials for the given alias.
	Retrieve(alias string) (ICredentials, error)

	// Delete deletes credentials for the given alias.
	Delete(alias string) error

	// List returns all stored credential aliases.
	List() ([]string, error)

	// IsExpired checks if credentials for the given alias are expired.
	IsExpired(alias string) (bool, error)

	// Type returns the type of credential store (e.g., "system-keyring", "noop").
	Type() string
}

CredentialStore defines the interface for storing and retrieving credentials.

type ICredentials

type ICredentials interface {
	IsExpired() bool

	GetExpiration() (*time.Time, error)

	BuildWhoamiInfo(info *WhoamiInfo)

	// Validate validates credentials by making an API call to the provider.
	// Returns validation info including principal (ARN/ID) and expiration, or error if invalid.
	// Returns ErrNotImplemented if validation is not supported for this credential type.
	Validate(ctx context.Context) (*ValidationInfo, error)
}

type Identity

type Identity interface {
	// Kind returns the identity kind (e.g., "aws/permission-set").
	Kind() string

	// GetProviderName returns the provider name for this identity.
	// AWS user identities return "aws-user", others return their via.provider.
	GetProviderName() (string, error)

	// Authenticate performs authentication using the provided base credentials.
	Authenticate(ctx context.Context, baseCreds ICredentials) (ICredentials, error)

	// Validate validates the identity configuration.
	Validate() error

	// Environment returns environment variables that should be set for this identity.
	Environment() (map[string]string, error)

	// PrepareEnvironment prepares environment variables for external processes (Terraform, workflows, etc.).
	// Takes current environment (already modified by provider's PrepareEnvironment) and returns
	// modified environment with identity-specific overrides.
	// Implementations should:
	//   - Add identity-specific environment variables (e.g., role ARN, session name)
	//   - Override provider defaults if needed
	//   - Return a NEW map without mutating the input
	PrepareEnvironment(ctx context.Context, environ map[string]string) (map[string]string, error)

	// PostAuthenticate is called after successful authentication with the final credentials.
	// It receives both authContext (to populate runtime credentials) and stackInfo (to read
	// stack-level auth configuration overrides and write environment variables).
	PostAuthenticate(ctx context.Context, params *PostAuthenticateParams) error

	// Logout removes identity-specific credential storage.
	// Best-effort: continue cleanup even if individual steps fail.
	Logout(ctx context.Context) error

	// CredentialsExist checks if credentials exist for this identity.
	// Used by whoami when noop keyring is active to verify credentials are present.
	// Returns true if credentials exist (in files, keyring, or other storage).
	CredentialsExist() (bool, error)

	// LoadCredentials loads credentials from identity-managed storage (files, etc.).
	// Used with noop keyring to enable credential validation in whoami.
	// Returns nil, nil if identity doesn't support loading credentials from storage.
	LoadCredentials(ctx context.Context) (ICredentials, error)
}

Identity defines the interface that all authentication identities must implement.

type MockAuthManager added in v1.196.0

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

MockAuthManager is a mock of AuthManager interface.

func NewMockAuthManager added in v1.196.0

func NewMockAuthManager(ctrl *gomock.Controller) *MockAuthManager

NewMockAuthManager creates a new mock instance.

func (*MockAuthManager) Authenticate added in v1.196.0

func (m *MockAuthManager) Authenticate(ctx context.Context, identityName string) (*WhoamiInfo, error)

Authenticate mocks base method.

func (*MockAuthManager) EXPECT added in v1.196.0

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockAuthManager) GetCachedCredentials added in v1.196.0

func (m *MockAuthManager) GetCachedCredentials(ctx context.Context, identityName string) (*WhoamiInfo, error)

GetCachedCredentials mocks base method.

func (*MockAuthManager) GetChain added in v1.196.0

func (m *MockAuthManager) GetChain() []string

GetChain mocks base method.

func (*MockAuthManager) GetDefaultIdentity added in v1.196.0

func (m *MockAuthManager) GetDefaultIdentity(forceSelect bool) (string, error)

GetDefaultIdentity mocks base method.

func (*MockAuthManager) GetEnvironmentVariables added in v1.196.0

func (m *MockAuthManager) GetEnvironmentVariables(identityName string) (map[string]string, error)

GetEnvironmentVariables mocks base method.

func (*MockAuthManager) GetFilesDisplayPath added in v1.196.0

func (m *MockAuthManager) GetFilesDisplayPath(providerName string) string

GetFilesDisplayPath mocks base method.

func (*MockAuthManager) GetIdentities added in v1.196.0

func (m *MockAuthManager) GetIdentities() map[string]schema.Identity

GetIdentities mocks base method.

func (*MockAuthManager) GetProviderForIdentity added in v1.196.0

func (m *MockAuthManager) GetProviderForIdentity(identityName string) string

GetProviderForIdentity mocks base method.

func (*MockAuthManager) GetProviderKindForIdentity added in v1.196.0

func (m *MockAuthManager) GetProviderKindForIdentity(identityName string) (string, error)

GetProviderKindForIdentity mocks base method.

func (*MockAuthManager) GetProviders added in v1.196.0

func (m *MockAuthManager) GetProviders() map[string]schema.Provider

GetProviders mocks base method.

func (*MockAuthManager) GetStackInfo added in v1.196.0

func (m *MockAuthManager) GetStackInfo() *schema.ConfigAndStacksInfo

GetStackInfo mocks base method.

func (*MockAuthManager) ListIdentities added in v1.196.0

func (m *MockAuthManager) ListIdentities() []string

ListIdentities mocks base method.

func (*MockAuthManager) ListProviders added in v1.196.0

func (m *MockAuthManager) ListProviders() []string

ListProviders mocks base method.

func (*MockAuthManager) Logout added in v1.196.0

func (m *MockAuthManager) Logout(ctx context.Context, identityName string) error

Logout mocks base method.

func (*MockAuthManager) LogoutAll added in v1.196.0

func (m *MockAuthManager) LogoutAll(ctx context.Context) error

LogoutAll mocks base method.

func (*MockAuthManager) LogoutProvider added in v1.196.0

func (m *MockAuthManager) LogoutProvider(ctx context.Context, providerName string) error

LogoutProvider mocks base method.

func (*MockAuthManager) PrepareShellEnvironment added in v1.197.0

func (m *MockAuthManager) PrepareShellEnvironment(ctx context.Context, identityName string, currentEnv []string) ([]string, error)

PrepareShellEnvironment mocks base method.

func (*MockAuthManager) Validate added in v1.196.0

func (m *MockAuthManager) Validate() error

Validate mocks base method.

func (*MockAuthManager) Whoami added in v1.196.0

func (m *MockAuthManager) Whoami(ctx context.Context, identityName string) (*WhoamiInfo, error)

Whoami mocks base method.

type MockAuthManagerMockRecorder added in v1.196.0

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

MockAuthManagerMockRecorder is the mock recorder for MockAuthManager.

func (*MockAuthManagerMockRecorder) Authenticate added in v1.196.0

func (mr *MockAuthManagerMockRecorder) Authenticate(ctx, identityName any) *gomock.Call

Authenticate indicates an expected call of Authenticate.

func (*MockAuthManagerMockRecorder) GetCachedCredentials added in v1.196.0

func (mr *MockAuthManagerMockRecorder) GetCachedCredentials(ctx, identityName any) *gomock.Call

GetCachedCredentials indicates an expected call of GetCachedCredentials.

func (*MockAuthManagerMockRecorder) GetChain added in v1.196.0

func (mr *MockAuthManagerMockRecorder) GetChain() *gomock.Call

GetChain indicates an expected call of GetChain.

func (*MockAuthManagerMockRecorder) GetDefaultIdentity added in v1.196.0

func (mr *MockAuthManagerMockRecorder) GetDefaultIdentity(forceSelect any) *gomock.Call

GetDefaultIdentity indicates an expected call of GetDefaultIdentity.

func (*MockAuthManagerMockRecorder) GetEnvironmentVariables added in v1.196.0

func (mr *MockAuthManagerMockRecorder) GetEnvironmentVariables(identityName any) *gomock.Call

GetEnvironmentVariables indicates an expected call of GetEnvironmentVariables.

func (*MockAuthManagerMockRecorder) GetFilesDisplayPath added in v1.196.0

func (mr *MockAuthManagerMockRecorder) GetFilesDisplayPath(providerName any) *gomock.Call

GetFilesDisplayPath indicates an expected call of GetFilesDisplayPath.

func (*MockAuthManagerMockRecorder) GetIdentities added in v1.196.0

func (mr *MockAuthManagerMockRecorder) GetIdentities() *gomock.Call

GetIdentities indicates an expected call of GetIdentities.

func (*MockAuthManagerMockRecorder) GetProviderForIdentity added in v1.196.0

func (mr *MockAuthManagerMockRecorder) GetProviderForIdentity(identityName any) *gomock.Call

GetProviderForIdentity indicates an expected call of GetProviderForIdentity.

func (*MockAuthManagerMockRecorder) GetProviderKindForIdentity added in v1.196.0

func (mr *MockAuthManagerMockRecorder) GetProviderKindForIdentity(identityName any) *gomock.Call

GetProviderKindForIdentity indicates an expected call of GetProviderKindForIdentity.

func (*MockAuthManagerMockRecorder) GetProviders added in v1.196.0

func (mr *MockAuthManagerMockRecorder) GetProviders() *gomock.Call

GetProviders indicates an expected call of GetProviders.

func (*MockAuthManagerMockRecorder) GetStackInfo added in v1.196.0

func (mr *MockAuthManagerMockRecorder) GetStackInfo() *gomock.Call

GetStackInfo indicates an expected call of GetStackInfo.

func (*MockAuthManagerMockRecorder) ListIdentities added in v1.196.0

func (mr *MockAuthManagerMockRecorder) ListIdentities() *gomock.Call

ListIdentities indicates an expected call of ListIdentities.

func (*MockAuthManagerMockRecorder) ListProviders added in v1.196.0

func (mr *MockAuthManagerMockRecorder) ListProviders() *gomock.Call

ListProviders indicates an expected call of ListProviders.

func (*MockAuthManagerMockRecorder) Logout added in v1.196.0

func (mr *MockAuthManagerMockRecorder) Logout(ctx, identityName any) *gomock.Call

Logout indicates an expected call of Logout.

func (*MockAuthManagerMockRecorder) LogoutAll added in v1.196.0

func (mr *MockAuthManagerMockRecorder) LogoutAll(ctx any) *gomock.Call

LogoutAll indicates an expected call of LogoutAll.

func (*MockAuthManagerMockRecorder) LogoutProvider added in v1.196.0

func (mr *MockAuthManagerMockRecorder) LogoutProvider(ctx, providerName any) *gomock.Call

LogoutProvider indicates an expected call of LogoutProvider.

func (*MockAuthManagerMockRecorder) PrepareShellEnvironment added in v1.197.0

func (mr *MockAuthManagerMockRecorder) PrepareShellEnvironment(ctx, identityName, currentEnv any) *gomock.Call

PrepareShellEnvironment indicates an expected call of PrepareShellEnvironment.

func (*MockAuthManagerMockRecorder) Validate added in v1.196.0

func (mr *MockAuthManagerMockRecorder) Validate() *gomock.Call

Validate indicates an expected call of Validate.

func (*MockAuthManagerMockRecorder) Whoami added in v1.196.0

func (mr *MockAuthManagerMockRecorder) Whoami(ctx, identityName any) *gomock.Call

Whoami indicates an expected call of Whoami.

type MockConsoleAccessProvider added in v1.196.0

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

MockConsoleAccessProvider is a mock of ConsoleAccessProvider interface.

func NewMockConsoleAccessProvider added in v1.196.0

func NewMockConsoleAccessProvider(ctrl *gomock.Controller) *MockConsoleAccessProvider

NewMockConsoleAccessProvider creates a new mock instance.

func (*MockConsoleAccessProvider) EXPECT added in v1.196.0

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockConsoleAccessProvider) GetConsoleURL added in v1.196.0

GetConsoleURL mocks base method.

func (*MockConsoleAccessProvider) SupportsConsoleAccess added in v1.196.0

func (m *MockConsoleAccessProvider) SupportsConsoleAccess() bool

SupportsConsoleAccess mocks base method.

type MockConsoleAccessProviderMockRecorder added in v1.196.0

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

MockConsoleAccessProviderMockRecorder is the mock recorder for MockConsoleAccessProvider.

func (*MockConsoleAccessProviderMockRecorder) GetConsoleURL added in v1.196.0

func (mr *MockConsoleAccessProviderMockRecorder) GetConsoleURL(ctx, creds, options any) *gomock.Call

GetConsoleURL indicates an expected call of GetConsoleURL.

func (*MockConsoleAccessProviderMockRecorder) SupportsConsoleAccess added in v1.196.0

func (mr *MockConsoleAccessProviderMockRecorder) SupportsConsoleAccess() *gomock.Call

SupportsConsoleAccess indicates an expected call of SupportsConsoleAccess.

type MockCredentialStore added in v1.196.0

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

MockCredentialStore is a mock of CredentialStore interface.

func NewMockCredentialStore added in v1.196.0

func NewMockCredentialStore(ctrl *gomock.Controller) *MockCredentialStore

NewMockCredentialStore creates a new mock instance.

func (*MockCredentialStore) Delete added in v1.196.0

func (m *MockCredentialStore) Delete(alias string) error

Delete mocks base method.

func (*MockCredentialStore) EXPECT added in v1.196.0

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockCredentialStore) IsExpired added in v1.196.0

func (m *MockCredentialStore) IsExpired(alias string) (bool, error)

IsExpired mocks base method.

func (*MockCredentialStore) List added in v1.196.0

func (m *MockCredentialStore) List() ([]string, error)

List mocks base method.

func (*MockCredentialStore) Retrieve added in v1.196.0

func (m *MockCredentialStore) Retrieve(alias string) (ICredentials, error)

Retrieve mocks base method.

func (*MockCredentialStore) Store added in v1.196.0

func (m *MockCredentialStore) Store(alias string, creds ICredentials) error

Store mocks base method.

func (*MockCredentialStore) Type added in v1.196.0

func (m *MockCredentialStore) Type() string

Type mocks base method.

type MockCredentialStoreMockRecorder added in v1.196.0

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

MockCredentialStoreMockRecorder is the mock recorder for MockCredentialStore.

func (*MockCredentialStoreMockRecorder) Delete added in v1.196.0

func (mr *MockCredentialStoreMockRecorder) Delete(alias any) *gomock.Call

Delete indicates an expected call of Delete.

func (*MockCredentialStoreMockRecorder) IsExpired added in v1.196.0

func (mr *MockCredentialStoreMockRecorder) IsExpired(alias any) *gomock.Call

IsExpired indicates an expected call of IsExpired.

func (*MockCredentialStoreMockRecorder) List added in v1.196.0

List indicates an expected call of List.

func (*MockCredentialStoreMockRecorder) Retrieve added in v1.196.0

func (mr *MockCredentialStoreMockRecorder) Retrieve(alias any) *gomock.Call

Retrieve indicates an expected call of Retrieve.

func (*MockCredentialStoreMockRecorder) Store added in v1.196.0

func (mr *MockCredentialStoreMockRecorder) Store(alias, creds any) *gomock.Call

Store indicates an expected call of Store.

func (*MockCredentialStoreMockRecorder) Type added in v1.196.0

Type indicates an expected call of Type.

type MockICredentials added in v1.196.0

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

MockICredentials is a mock of ICredentials interface.

func NewMockICredentials added in v1.196.0

func NewMockICredentials(ctrl *gomock.Controller) *MockICredentials

NewMockICredentials creates a new mock instance.

func (*MockICredentials) BuildWhoamiInfo added in v1.196.0

func (m *MockICredentials) BuildWhoamiInfo(info *WhoamiInfo)

BuildWhoamiInfo mocks base method.

func (*MockICredentials) EXPECT added in v1.196.0

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockICredentials) GetExpiration added in v1.196.0

func (m *MockICredentials) GetExpiration() (*time.Time, error)

GetExpiration mocks base method.

func (*MockICredentials) IsExpired added in v1.196.0

func (m *MockICredentials) IsExpired() bool

IsExpired mocks base method.

func (*MockICredentials) Validate added in v1.196.0

func (m *MockICredentials) Validate(ctx context.Context) (*ValidationInfo, error)

Validate mocks base method.

type MockICredentialsMockRecorder added in v1.196.0

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

MockICredentialsMockRecorder is the mock recorder for MockICredentials.

func (*MockICredentialsMockRecorder) BuildWhoamiInfo added in v1.196.0

func (mr *MockICredentialsMockRecorder) BuildWhoamiInfo(info any) *gomock.Call

BuildWhoamiInfo indicates an expected call of BuildWhoamiInfo.

func (*MockICredentialsMockRecorder) GetExpiration added in v1.196.0

func (mr *MockICredentialsMockRecorder) GetExpiration() *gomock.Call

GetExpiration indicates an expected call of GetExpiration.

func (*MockICredentialsMockRecorder) IsExpired added in v1.196.0

func (mr *MockICredentialsMockRecorder) IsExpired() *gomock.Call

IsExpired indicates an expected call of IsExpired.

func (*MockICredentialsMockRecorder) Validate added in v1.196.0

func (mr *MockICredentialsMockRecorder) Validate(ctx any) *gomock.Call

Validate indicates an expected call of Validate.

type MockIdentity added in v1.196.0

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

MockIdentity is a mock of Identity interface.

func NewMockIdentity added in v1.196.0

func NewMockIdentity(ctrl *gomock.Controller) *MockIdentity

NewMockIdentity creates a new mock instance.

func (*MockIdentity) Authenticate added in v1.196.0

func (m *MockIdentity) Authenticate(ctx context.Context, baseCreds ICredentials) (ICredentials, error)

Authenticate mocks base method.

func (*MockIdentity) CredentialsExist added in v1.196.0

func (m *MockIdentity) CredentialsExist() (bool, error)

CredentialsExist mocks base method.

func (*MockIdentity) EXPECT added in v1.196.0

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockIdentity) Environment added in v1.196.0

func (m *MockIdentity) Environment() (map[string]string, error)

Environment mocks base method.

func (*MockIdentity) GetProviderName added in v1.196.0

func (m *MockIdentity) GetProviderName() (string, error)

GetProviderName mocks base method.

func (*MockIdentity) Kind added in v1.196.0

func (m *MockIdentity) Kind() string

Kind mocks base method.

func (*MockIdentity) LoadCredentials added in v1.196.0

func (m *MockIdentity) LoadCredentials(ctx context.Context) (ICredentials, error)

LoadCredentials mocks base method.

func (*MockIdentity) Logout added in v1.196.0

func (m *MockIdentity) Logout(ctx context.Context) error

Logout mocks base method.

func (*MockIdentity) PostAuthenticate added in v1.196.0

func (m *MockIdentity) PostAuthenticate(ctx context.Context, params *PostAuthenticateParams) error

PostAuthenticate mocks base method.

func (*MockIdentity) PrepareEnvironment added in v1.196.0

func (m *MockIdentity) PrepareEnvironment(ctx context.Context, environ map[string]string) (map[string]string, error)

PrepareEnvironment mocks base method.

func (*MockIdentity) Validate added in v1.196.0

func (m *MockIdentity) Validate() error

Validate mocks base method.

type MockIdentityMockRecorder added in v1.196.0

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

MockIdentityMockRecorder is the mock recorder for MockIdentity.

func (*MockIdentityMockRecorder) Authenticate added in v1.196.0

func (mr *MockIdentityMockRecorder) Authenticate(ctx, baseCreds any) *gomock.Call

Authenticate indicates an expected call of Authenticate.

func (*MockIdentityMockRecorder) CredentialsExist added in v1.196.0

func (mr *MockIdentityMockRecorder) CredentialsExist() *gomock.Call

CredentialsExist indicates an expected call of CredentialsExist.

func (*MockIdentityMockRecorder) Environment added in v1.196.0

func (mr *MockIdentityMockRecorder) Environment() *gomock.Call

Environment indicates an expected call of Environment.

func (*MockIdentityMockRecorder) GetProviderName added in v1.196.0

func (mr *MockIdentityMockRecorder) GetProviderName() *gomock.Call

GetProviderName indicates an expected call of GetProviderName.

func (*MockIdentityMockRecorder) Kind added in v1.196.0

func (mr *MockIdentityMockRecorder) Kind() *gomock.Call

Kind indicates an expected call of Kind.

func (*MockIdentityMockRecorder) LoadCredentials added in v1.196.0

func (mr *MockIdentityMockRecorder) LoadCredentials(ctx any) *gomock.Call

LoadCredentials indicates an expected call of LoadCredentials.

func (*MockIdentityMockRecorder) Logout added in v1.196.0

func (mr *MockIdentityMockRecorder) Logout(ctx any) *gomock.Call

Logout indicates an expected call of Logout.

func (*MockIdentityMockRecorder) PostAuthenticate added in v1.196.0

func (mr *MockIdentityMockRecorder) PostAuthenticate(ctx, params any) *gomock.Call

PostAuthenticate indicates an expected call of PostAuthenticate.

func (*MockIdentityMockRecorder) PrepareEnvironment added in v1.196.0

func (mr *MockIdentityMockRecorder) PrepareEnvironment(ctx, environ any) *gomock.Call

PrepareEnvironment indicates an expected call of PrepareEnvironment.

func (*MockIdentityMockRecorder) Validate added in v1.196.0

func (mr *MockIdentityMockRecorder) Validate() *gomock.Call

Validate indicates an expected call of Validate.

type MockProvider added in v1.196.0

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

MockProvider is a mock of Provider interface.

func NewMockProvider added in v1.196.0

func NewMockProvider(ctrl *gomock.Controller) *MockProvider

NewMockProvider creates a new mock instance.

func (*MockProvider) Authenticate added in v1.196.0

func (m *MockProvider) Authenticate(ctx context.Context) (ICredentials, error)

Authenticate mocks base method.

func (*MockProvider) EXPECT added in v1.196.0

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockProvider) Environment added in v1.196.0

func (m *MockProvider) Environment() (map[string]string, error)

Environment mocks base method.

func (*MockProvider) GetFilesDisplayPath added in v1.196.0

func (m *MockProvider) GetFilesDisplayPath() string

GetFilesDisplayPath mocks base method.

func (*MockProvider) Kind added in v1.196.0

func (m *MockProvider) Kind() string

Kind mocks base method.

func (*MockProvider) Logout added in v1.196.0

func (m *MockProvider) Logout(ctx context.Context) error

Logout mocks base method.

func (*MockProvider) Name added in v1.196.0

func (m *MockProvider) Name() string

Name mocks base method.

func (*MockProvider) PreAuthenticate added in v1.196.0

func (m *MockProvider) PreAuthenticate(manager AuthManager) error

PreAuthenticate mocks base method.

func (*MockProvider) PrepareEnvironment added in v1.196.0

func (m *MockProvider) PrepareEnvironment(ctx context.Context, environ map[string]string) (map[string]string, error)

PrepareEnvironment mocks base method.

func (*MockProvider) Validate added in v1.196.0

func (m *MockProvider) Validate() error

Validate mocks base method.

type MockProviderMockRecorder added in v1.196.0

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

MockProviderMockRecorder is the mock recorder for MockProvider.

func (*MockProviderMockRecorder) Authenticate added in v1.196.0

func (mr *MockProviderMockRecorder) Authenticate(ctx any) *gomock.Call

Authenticate indicates an expected call of Authenticate.

func (*MockProviderMockRecorder) Environment added in v1.196.0

func (mr *MockProviderMockRecorder) Environment() *gomock.Call

Environment indicates an expected call of Environment.

func (*MockProviderMockRecorder) GetFilesDisplayPath added in v1.196.0

func (mr *MockProviderMockRecorder) GetFilesDisplayPath() *gomock.Call

GetFilesDisplayPath indicates an expected call of GetFilesDisplayPath.

func (*MockProviderMockRecorder) Kind added in v1.196.0

func (mr *MockProviderMockRecorder) Kind() *gomock.Call

Kind indicates an expected call of Kind.

func (*MockProviderMockRecorder) Logout added in v1.196.0

func (mr *MockProviderMockRecorder) Logout(ctx any) *gomock.Call

Logout indicates an expected call of Logout.

func (*MockProviderMockRecorder) Name added in v1.196.0

func (mr *MockProviderMockRecorder) Name() *gomock.Call

Name indicates an expected call of Name.

func (*MockProviderMockRecorder) PreAuthenticate added in v1.196.0

func (mr *MockProviderMockRecorder) PreAuthenticate(manager any) *gomock.Call

PreAuthenticate indicates an expected call of PreAuthenticate.

func (*MockProviderMockRecorder) PrepareEnvironment added in v1.196.0

func (mr *MockProviderMockRecorder) PrepareEnvironment(ctx, environ any) *gomock.Call

PrepareEnvironment indicates an expected call of PrepareEnvironment.

func (*MockProviderMockRecorder) Validate added in v1.196.0

func (mr *MockProviderMockRecorder) Validate() *gomock.Call

Validate indicates an expected call of Validate.

type MockValidator added in v1.196.0

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

MockValidator is a mock of Validator interface.

func NewMockValidator added in v1.196.0

func NewMockValidator(ctrl *gomock.Controller) *MockValidator

NewMockValidator creates a new mock instance.

func (*MockValidator) EXPECT added in v1.196.0

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockValidator) ValidateAuthConfig added in v1.196.0

func (m *MockValidator) ValidateAuthConfig(config *schema.AuthConfig) error

ValidateAuthConfig mocks base method.

func (*MockValidator) ValidateChains added in v1.196.0

func (m *MockValidator) ValidateChains(identities map[string]*schema.Identity, providers map[string]*schema.Provider) error

ValidateChains mocks base method.

func (*MockValidator) ValidateIdentity added in v1.196.0

func (m *MockValidator) ValidateIdentity(name string, identity *schema.Identity, providers map[string]*schema.Provider) error

ValidateIdentity mocks base method.

func (*MockValidator) ValidateProvider added in v1.196.0

func (m *MockValidator) ValidateProvider(name string, provider *schema.Provider) error

ValidateProvider mocks base method.

type MockValidatorMockRecorder added in v1.196.0

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

MockValidatorMockRecorder is the mock recorder for MockValidator.

func (*MockValidatorMockRecorder) ValidateAuthConfig added in v1.196.0

func (mr *MockValidatorMockRecorder) ValidateAuthConfig(config any) *gomock.Call

ValidateAuthConfig indicates an expected call of ValidateAuthConfig.

func (*MockValidatorMockRecorder) ValidateChains added in v1.196.0

func (mr *MockValidatorMockRecorder) ValidateChains(identities, providers any) *gomock.Call

ValidateChains indicates an expected call of ValidateChains.

func (*MockValidatorMockRecorder) ValidateIdentity added in v1.196.0

func (mr *MockValidatorMockRecorder) ValidateIdentity(name, identity, providers any) *gomock.Call

ValidateIdentity indicates an expected call of ValidateIdentity.

func (*MockValidatorMockRecorder) ValidateProvider added in v1.196.0

func (mr *MockValidatorMockRecorder) ValidateProvider(name, provider any) *gomock.Call

ValidateProvider indicates an expected call of ValidateProvider.

type OIDCCredentials

type OIDCCredentials struct {
	Token    string `json:"token,omitempty"`
	Provider string `json:"provider,omitempty"`
	Audience string `json:"audience,omitempty"`
}

OIDCCredentials defines OIDC-specific credential fields.

func (*OIDCCredentials) BuildWhoamiInfo

func (c *OIDCCredentials) BuildWhoamiInfo(info *WhoamiInfo)

BuildWhoamiInfo implements ICredentials for OIDCCredentials.

func (*OIDCCredentials) GetExpiration

func (c *OIDCCredentials) GetExpiration() (*time.Time, error)

GetExpiration implements ICredentials for OIDCCredentials.

func (*OIDCCredentials) IsExpired

func (c *OIDCCredentials) IsExpired() bool

IsExpired implements ICredentials for OIDCCredentials. If no expiration tracking exists, default to not expired.

func (*OIDCCredentials) Validate added in v1.196.0

func (c *OIDCCredentials) Validate(ctx context.Context) (*ValidationInfo, error)

Validate is not implemented for OIDC credentials. OIDC tokens cannot be validated without provider-specific logic.

type PostAuthenticateParams added in v1.196.0

type PostAuthenticateParams struct {
	AuthContext  *schema.AuthContext
	StackInfo    *schema.ConfigAndStacksInfo
	ProviderName string
	IdentityName string
	Credentials  ICredentials
	Manager      AuthManager // Auth manager for resolving provider chains
}

PostAuthenticateParams contains parameters for PostAuthenticate method.

type Provider

type Provider interface {
	// Kind returns the provider kind (e.g., "aws/iam-identity-center").
	Kind() string
	// Name returns the provider name as defined in configuration.
	Name() string
	// PreAuthenticate allows the provider to inspect the authentication chain prior to authentication
	// so that it can set up any provider-specific preferences based on downstream identities (e.g.,
	// preferred role ARN for SAML based on the next identity in the chain).
	// Implementations should be side-effect free beyond local provider state.
	// Providers can access the current chain via manager.GetChain().
	PreAuthenticate(manager AuthManager) error
	// Authenticate performs provider-specific authentication and returns credentials.
	Authenticate(ctx context.Context) (ICredentials, error)

	// Validate validates the provider configuration.
	Validate() error

	// Environment returns environment variables that should be set for this provider.
	Environment() (map[string]string, error)

	// PrepareEnvironment prepares environment variables for external processes (Terraform, workflows, etc.).
	// Takes current environment and returns modified environment suitable for the provider's SDK/CLI.
	// Implementations should:
	//   - Clear conflicting credential environment variables
	//   - Set provider-specific configuration (credential files, profiles, regions)
	//   - Return a NEW map without mutating the input
	PrepareEnvironment(ctx context.Context, environ map[string]string) (map[string]string, error)

	// Logout removes provider-specific credential storage (files, cache, etc.).
	// Returns error only if cleanup fails for critical resources.
	// Best-effort: continue cleanup even if individual steps fail.
	Logout(ctx context.Context) error

	// GetFilesDisplayPath returns the display path for credential files.
	// Returns the configured path if set, otherwise a default path.
	// For display purposes only (may use ~ for home directory).
	GetFilesDisplayPath() string
}

Provider defines the interface that all authentication providers must implement.

type ValidationInfo added in v1.196.0

type ValidationInfo struct {
	// Principal is the authenticated principal identifier.
	// For AWS: ARN (e.g., "arn:aws:iam::123456789012:user/username").
	// For Azure: Object ID or User Principal Name.
	// For GCP: Service account email or user email.
	Principal string

	// Account is the account/organization identifier.
	// For AWS: Account ID (e.g., "123456789012").
	// For Azure: Tenant ID.
	// For GCP: Project ID.
	Account string

	// Expiration is when the credentials expire (if temporary).
	Expiration *time.Time
}

ValidationInfo contains cloud-agnostic validation results from credential verification.

type Validator

type Validator interface {
	// ValidateAuthConfig validates the entire auth configuration.
	ValidateAuthConfig(config *schema.AuthConfig) error

	// ValidateProvider validates a provider configuration.
	ValidateProvider(name string, provider *schema.Provider) error

	// ValidateIdentity validates an identity configuration.
	ValidateIdentity(name string, identity *schema.Identity, providers map[string]*schema.Provider) error

	// ValidateChains validates identity chains for cycles and invalid references.
	ValidateChains(identities map[string]*schema.Identity, providers map[string]*schema.Provider) error
}

Validator defines the interface for validating auth configurations.

type WhoamiInfo

type WhoamiInfo struct {
	Provider    string            `json:"provider"`
	Identity    string            `json:"identity"`
	Principal   string            `json:"principal"`
	Account     string            `json:"account,omitempty"`
	Region      string            `json:"region,omitempty"`
	Expiration  *time.Time        `json:"expiration,omitempty"`
	Environment map[string]string `json:"environment,omitempty"`

	// Credentials holds raw credential material and must never be serialized.
	// Ensure secrets/tokens are not exposed via JSON or YAML outputs.
	Credentials ICredentials `json:"-" yaml:"-"`

	// CredentialsRef holds an opaque keystore handle for rehydrating credentials without exposing secrets.
	CredentialsRef string    `json:"credentials_ref,omitempty" yaml:"credentials_ref,omitempty"`
	LastUpdated    time.Time `json:"last_updated"`
}

WhoamiInfo represents the current effective authentication principal.

func (*WhoamiInfo) Rehydrate

func (w *WhoamiInfo) Rehydrate(store CredentialStore) error

Rehydrate ensures that the Credentials field is populated by retrieving the underlying secret material from the provided credential store if Credentials is nil and a non-empty CredentialsRef is available. This avoids exposing secrets during serialization while allowing consumers to lazily fetch them when needed.

Jump to

Keyboard shortcuts

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