Documentation
¶
Overview ¶
Package types is a generated GoMock package.
Index ¶
- Constants
- func AllowPrompts(ctx context.Context) bool
- func WithAllowPrompts(ctx context.Context, allowPrompts bool) context.Context
- type AWSCredentials
- type AuthManager
- type AzureCredentials
- type ConsoleAccessProvider
- type ConsoleURLOptions
- type CredentialField
- type CredentialPromptFunc
- type CredentialPromptResult
- type CredentialPromptSpec
- type CredentialStore
- type ICredentials
- type Identity
- type MockAuthManager
- func (m *MockAuthManager) Authenticate(ctx context.Context, identityName string) (*WhoamiInfo, error)
- func (m *MockAuthManager) AuthenticateProvider(ctx context.Context, providerName string) (*WhoamiInfo, error)
- func (m *MockAuthManager) EXPECT() *MockAuthManagerMockRecorder
- func (m *MockAuthManager) ExecuteIdentityIntegrations(ctx context.Context, identityName string) error
- func (m *MockAuthManager) ExecuteIntegration(ctx context.Context, integrationName string) error
- func (m *MockAuthManager) GetCachedCredentials(ctx context.Context, identityName string) (*WhoamiInfo, error)
- func (m *MockAuthManager) GetChain() []string
- func (m *MockAuthManager) GetDefaultIdentity(forceSelect bool) (string, error)
- func (m *MockAuthManager) GetEnvironmentVariables(identityName string) (map[string]string, error)
- func (m *MockAuthManager) GetFilesDisplayPath(providerName string) string
- func (m *MockAuthManager) GetIdentities() map[string]schema.Identity
- func (m *MockAuthManager) GetIntegration(integrationName string) (*schema.Integration, error)
- func (m *MockAuthManager) GetProviderForIdentity(identityName string) string
- func (m *MockAuthManager) GetProviderKindForIdentity(identityName string) (string, error)
- func (m *MockAuthManager) GetProviders() map[string]schema.Provider
- func (m *MockAuthManager) GetRealm() realm.RealmInfo
- func (m *MockAuthManager) GetStackInfo() *schema.ConfigAndStacksInfo
- func (m *MockAuthManager) ListIdentities() []string
- func (m *MockAuthManager) ListProviders() []string
- func (m *MockAuthManager) Logout(ctx context.Context, identityName string, deleteKeychain bool) error
- func (m *MockAuthManager) LogoutAll(ctx context.Context, deleteKeychain bool) error
- func (m *MockAuthManager) LogoutProvider(ctx context.Context, providerName string, deleteKeychain bool) error
- func (m *MockAuthManager) PrepareShellEnvironment(ctx context.Context, identityName string, currentEnv []string) ([]string, error)
- func (m *MockAuthManager) ResolvePrincipalSetting(identityName, key string) (any, bool)
- func (m *MockAuthManager) ResolveProviderConfig(identityName string) (*schema.Provider, bool)
- func (m *MockAuthManager) Validate() error
- func (m *MockAuthManager) Whoami(ctx context.Context, identityName string) (*WhoamiInfo, error)
- type MockAuthManagerMockRecorder
- func (mr *MockAuthManagerMockRecorder) Authenticate(ctx, identityName any) *gomock.Call
- func (mr *MockAuthManagerMockRecorder) AuthenticateProvider(ctx, providerName any) *gomock.Call
- func (mr *MockAuthManagerMockRecorder) ExecuteIdentityIntegrations(ctx, identityName any) *gomock.Call
- func (mr *MockAuthManagerMockRecorder) ExecuteIntegration(ctx, integrationName any) *gomock.Call
- func (mr *MockAuthManagerMockRecorder) GetCachedCredentials(ctx, identityName any) *gomock.Call
- func (mr *MockAuthManagerMockRecorder) GetChain() *gomock.Call
- func (mr *MockAuthManagerMockRecorder) GetDefaultIdentity(forceSelect any) *gomock.Call
- func (mr *MockAuthManagerMockRecorder) GetEnvironmentVariables(identityName any) *gomock.Call
- func (mr *MockAuthManagerMockRecorder) GetFilesDisplayPath(providerName any) *gomock.Call
- func (mr *MockAuthManagerMockRecorder) GetIdentities() *gomock.Call
- func (mr *MockAuthManagerMockRecorder) GetIntegration(integrationName any) *gomock.Call
- func (mr *MockAuthManagerMockRecorder) GetProviderForIdentity(identityName any) *gomock.Call
- func (mr *MockAuthManagerMockRecorder) GetProviderKindForIdentity(identityName any) *gomock.Call
- func (mr *MockAuthManagerMockRecorder) GetProviders() *gomock.Call
- func (mr *MockAuthManagerMockRecorder) GetRealm() *gomock.Call
- func (mr *MockAuthManagerMockRecorder) GetStackInfo() *gomock.Call
- func (mr *MockAuthManagerMockRecorder) ListIdentities() *gomock.Call
- func (mr *MockAuthManagerMockRecorder) ListProviders() *gomock.Call
- func (mr *MockAuthManagerMockRecorder) Logout(ctx, identityName, deleteKeychain any) *gomock.Call
- func (mr *MockAuthManagerMockRecorder) LogoutAll(ctx, deleteKeychain any) *gomock.Call
- func (mr *MockAuthManagerMockRecorder) LogoutProvider(ctx, providerName, deleteKeychain any) *gomock.Call
- func (mr *MockAuthManagerMockRecorder) PrepareShellEnvironment(ctx, identityName, currentEnv any) *gomock.Call
- func (mr *MockAuthManagerMockRecorder) ResolvePrincipalSetting(identityName, key any) *gomock.Call
- func (mr *MockAuthManagerMockRecorder) ResolveProviderConfig(identityName any) *gomock.Call
- func (mr *MockAuthManagerMockRecorder) Validate() *gomock.Call
- func (mr *MockAuthManagerMockRecorder) Whoami(ctx, identityName any) *gomock.Call
- type MockConsoleAccessProvider
- type MockConsoleAccessProviderMockRecorder
- type MockCredentialStore
- func (m *MockCredentialStore) Delete(alias, arg1 string) error
- func (m *MockCredentialStore) EXPECT() *MockCredentialStoreMockRecorder
- func (m *MockCredentialStore) IsExpired(alias, arg1 string) (bool, error)
- func (m *MockCredentialStore) List(arg0 string) ([]string, error)
- func (m *MockCredentialStore) Retrieve(alias, arg1 string) (ICredentials, error)
- func (m *MockCredentialStore) Store(alias string, creds ICredentials, arg2 string) error
- func (m *MockCredentialStore) Type() string
- type MockCredentialStoreMockRecorder
- func (mr *MockCredentialStoreMockRecorder) Delete(alias, arg1 any) *gomock.Call
- func (mr *MockCredentialStoreMockRecorder) IsExpired(alias, arg1 any) *gomock.Call
- func (mr *MockCredentialStoreMockRecorder) List(arg0 any) *gomock.Call
- func (mr *MockCredentialStoreMockRecorder) Retrieve(alias, arg1 any) *gomock.Call
- func (mr *MockCredentialStoreMockRecorder) Store(alias, creds, arg2 any) *gomock.Call
- func (mr *MockCredentialStoreMockRecorder) Type() *gomock.Call
- type MockICredentials
- func (m *MockICredentials) BuildWhoamiInfo(info *WhoamiInfo)
- func (m *MockICredentials) EXPECT() *MockICredentialsMockRecorder
- func (m *MockICredentials) GetExpiration() (*time.Time, error)
- func (m *MockICredentials) IsExpired() bool
- func (m *MockICredentials) Validate(ctx context.Context) (*ValidationInfo, error)
- type MockICredentialsMockRecorder
- type MockIdentity
- func (m *MockIdentity) Authenticate(ctx context.Context, baseCreds ICredentials) (ICredentials, error)
- func (m *MockIdentity) CredentialsExist() (bool, error)
- func (m *MockIdentity) EXPECT() *MockIdentityMockRecorder
- func (m *MockIdentity) Environment() (map[string]string, error)
- func (m *MockIdentity) GetProviderName() (string, error)
- func (m *MockIdentity) Kind() string
- func (m *MockIdentity) LoadCredentials(ctx context.Context) (ICredentials, error)
- func (m *MockIdentity) Logout(ctx context.Context) error
- func (m *MockIdentity) Paths() ([]Path, error)
- func (m *MockIdentity) PostAuthenticate(ctx context.Context, params *PostAuthenticateParams) error
- func (m *MockIdentity) PrepareEnvironment(ctx context.Context, environ map[string]string) (map[string]string, error)
- func (m *MockIdentity) SetRealm(arg0 string)
- func (m *MockIdentity) Validate() error
- type MockIdentityMockRecorder
- func (mr *MockIdentityMockRecorder) Authenticate(ctx, baseCreds any) *gomock.Call
- func (mr *MockIdentityMockRecorder) CredentialsExist() *gomock.Call
- func (mr *MockIdentityMockRecorder) Environment() *gomock.Call
- func (mr *MockIdentityMockRecorder) GetProviderName() *gomock.Call
- func (mr *MockIdentityMockRecorder) Kind() *gomock.Call
- func (mr *MockIdentityMockRecorder) LoadCredentials(ctx any) *gomock.Call
- func (mr *MockIdentityMockRecorder) Logout(ctx any) *gomock.Call
- func (mr *MockIdentityMockRecorder) Paths() *gomock.Call
- func (mr *MockIdentityMockRecorder) PostAuthenticate(ctx, params any) *gomock.Call
- func (mr *MockIdentityMockRecorder) PrepareEnvironment(ctx, environ any) *gomock.Call
- func (mr *MockIdentityMockRecorder) SetRealm(arg0 any) *gomock.Call
- func (mr *MockIdentityMockRecorder) Validate() *gomock.Call
- type MockProvider
- func (m *MockProvider) Authenticate(ctx context.Context) (ICredentials, error)
- func (m *MockProvider) EXPECT() *MockProviderMockRecorder
- func (m *MockProvider) Environment() (map[string]string, error)
- func (m *MockProvider) GetFilesDisplayPath() string
- func (m *MockProvider) Kind() string
- func (m *MockProvider) Logout(ctx context.Context) error
- func (m *MockProvider) Name() string
- func (m *MockProvider) Paths() ([]Path, error)
- func (m *MockProvider) PreAuthenticate(manager AuthManager) error
- func (m *MockProvider) PrepareEnvironment(ctx context.Context, environ map[string]string) (map[string]string, error)
- func (m *MockProvider) SetRealm(arg0 string)
- func (m *MockProvider) Validate() error
- type MockProviderMockRecorder
- func (mr *MockProviderMockRecorder) Authenticate(ctx any) *gomock.Call
- func (mr *MockProviderMockRecorder) Environment() *gomock.Call
- func (mr *MockProviderMockRecorder) GetFilesDisplayPath() *gomock.Call
- func (mr *MockProviderMockRecorder) Kind() *gomock.Call
- func (mr *MockProviderMockRecorder) Logout(ctx any) *gomock.Call
- func (mr *MockProviderMockRecorder) Name() *gomock.Call
- func (mr *MockProviderMockRecorder) Paths() *gomock.Call
- func (mr *MockProviderMockRecorder) PreAuthenticate(manager any) *gomock.Call
- func (mr *MockProviderMockRecorder) PrepareEnvironment(ctx, environ any) *gomock.Call
- func (mr *MockProviderMockRecorder) SetRealm(arg0 any) *gomock.Call
- func (mr *MockProviderMockRecorder) Validate() *gomock.Call
- type MockProvisioner
- type MockProvisionerMockRecorder
- type MockValidator
- func (m *MockValidator) EXPECT() *MockValidatorMockRecorder
- func (m *MockValidator) ValidateAuthConfig(config *schema.AuthConfig) error
- func (m *MockValidator) ValidateChains(identities map[string]*schema.Identity, providers map[string]*schema.Provider) error
- func (m *MockValidator) ValidateIdentity(name string, identity *schema.Identity, providers map[string]*schema.Provider) error
- func (m *MockValidator) ValidateProvider(name string, provider *schema.Provider) error
- type MockValidatorMockRecorder
- func (mr *MockValidatorMockRecorder) ValidateAuthConfig(config any) *gomock.Call
- func (mr *MockValidatorMockRecorder) ValidateChains(identities, providers any) *gomock.Call
- func (mr *MockValidatorMockRecorder) ValidateIdentity(name, identity, providers any) *gomock.Call
- func (mr *MockValidatorMockRecorder) ValidateProvider(name, provider any) *gomock.Call
- type OIDCCredentials
- type Path
- type PathType
- type PostAuthenticateParams
- type Provider
- type Provisioner
- type ProvisioningCounts
- type ProvisioningMetadata
- type ProvisioningResult
- type ProvisioningWriter
- type ValidationInfo
- type Validator
- type WhoamiInfo
Constants ¶
const ( // AWS provider kinds. ProviderKindAWSIAMIdentityCenter = "aws/iam-identity-center" ProviderKindAWSSAML = "aws/saml" ProviderKindAWSUser = "aws/user" ProviderKindAWSAssumeRole = "aws/assume-role" ProviderKindAWSPermissionSet = "aws/permission-set" ProviderKindAWSAssumeRoot = "aws/assume-root" // Azure provider kinds. ProviderKindAzureOIDC = "azure/oidc" ProviderKindAzureCLI = "azure/cli" ProviderKindAzureDeviceCode = "azure/device-code" // GCP provider kinds. ProviderKindGCPOIDC = "gcp/oidc" // GitHub provider kinds. ProviderKindGitHubOIDC = "github/oidc" )
Provider kind constants for identifying provider types.
const ( CredentialStoreTypeSystemKeyring = "system-keyring" CredentialStoreTypeNoop = "noop" CredentialStoreTypeMemory = "memory" CredentialStoreTypeFile = "file" )
Credential store type constants.
const ( // ContextKeyAllowPrompts is the context key for controlling whether credential prompts are allowed. // When set to false, authentication flows should not prompt for credentials. ContextKeyAllowPrompts contextKey = "atmos-auth-allow-prompts" )
Variables ¶
This section is empty.
Functions ¶
func AllowPrompts ¶ added in v1.203.0
AllowPrompts returns whether credential prompts are allowed in this context. Returns true if the flag is not set (default behavior allows prompts).
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)
// AuthenticateProvider performs authentication directly with a provider.
// This is used for provider-level operations like SSO auto-provisioning where
// you want to authenticate to a provider without specifying a particular identity.
// If the provider has auto_provision_identities enabled, this will trigger
// automatic discovery and provisioning of all available identities.
// Use this when you want to authenticate to a provider (e.g., `auth login --provider sso-prod`).
AuthenticateProvider(ctx context.Context, providerName 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
// GetRealm returns the computed realm information for this auth manager.
// The realm provides credential isolation between different repositories.
GetRealm() realm.RealmInfo
// 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.
// If deleteKeychain is true, also removes credentials from system keychain.
// Best-effort: continues cleanup even if individual steps fail.
Logout(ctx context.Context, identityName string, deleteKeychain bool) error
// LogoutProvider removes all credentials for the specified provider.
// If deleteKeychain is true, also removes credentials from system keychain.
// Best-effort: continues cleanup even if individual steps fail.
LogoutProvider(ctx context.Context, providerName string, deleteKeychain bool) error
// LogoutAll removes all cached credentials for all identities.
// If deleteKeychain is true, also removes credentials from system keychain.
// Best-effort: continues cleanup even if individual steps fail.
LogoutAll(ctx context.Context, deleteKeychain bool) 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)
// ExecuteIntegration executes a named integration.
// This authenticates the integration's linked identity first, then executes the integration.
// Use this for explicit integration execution via `atmos auth ecr-login <integration>`.
ExecuteIntegration(ctx context.Context, integrationName string) error
// ExecuteIdentityIntegrations executes all linked integrations for an identity.
// This authenticates the identity first, then executes all its linked integrations.
// Use this for `atmos auth ecr-login --identity <identity>`.
ExecuteIdentityIntegrations(ctx context.Context, identityName string) error
// GetIntegration returns the integration config by name.
GetIntegration(integrationName string) (*schema.Integration, error)
// ResolvePrincipalSetting traverses the identity chain and returns the first
// non-empty value for the given key in Principal configuration.
// The chain is traversed from the target identity backwards through parent identities.
// This is a provider-agnostic mechanism for inheriting settings through the chain.
// Returns the value and true if found, nil and false otherwise.
ResolvePrincipalSetting(identityName, key string) (interface{}, bool)
// ResolveProviderConfig returns the provider configuration at the root of
// the identity's authentication chain.
// This allows identities to access provider-level settings without knowing
// the specific provider name.
// Returns the provider config and true if found, nil and false otherwise.
ResolveProviderConfig(identityName string) (*schema.Provider, bool)
}
AuthManager manages the overall authentication process.
type AzureCredentials ¶ added in v1.199.0
type AzureCredentials struct {
AccessToken string `json:"access_token,omitempty"`
TokenType string `json:"token_type,omitempty"` // Usually "Bearer"
Expiration string `json:"expiration,omitempty"` // RFC3339 timestamp
TenantID string `json:"tenant_id,omitempty"` // Azure AD tenant ID
SubscriptionID string `json:"subscription_id,omitempty"` // Azure subscription ID
Location string `json:"location,omitempty"` // Azure region (e.g., "eastus")
GraphAPIToken string `json:"graph_api_token,omitempty"` // Microsoft Graph API token
GraphAPIExpiration string `json:"graph_api_expiration,omitempty"` // RFC3339 timestamp for Graph API token
KeyVaultToken string `json:"key_vault_token,omitempty"` // Azure KeyVault API token
KeyVaultExpiration string `json:"key_vault_expiration,omitempty"` // RFC3339 timestamp for KeyVault token
// ClientID is set for service principal authentication (OIDC).
// When set, MSAL cache uses client credentials format instead of user format.
ClientID string `json:"client_id,omitempty"`
// IsServicePrincipal indicates this is service principal auth (OIDC/client credentials).
// Service principal tokens use a different MSAL cache format than user tokens.
IsServicePrincipal bool `json:"is_service_principal,omitempty"`
// TokenFilePath is the path to the OIDC token file (e.g., from GitHub Actions).
// Used for Terraform ARM_USE_OIDC authentication.
TokenFilePath string `json:"token_file_path,omitempty"`
// FederatedToken is the actual OIDC/federated token value.
// This is stored during authentication for use by Azure CLI.
// In GitHub Actions, this is obtained dynamically, not from a file.
FederatedToken string `json:"-"` // Don't persist - it's ephemeral.
}
AzureCredentials defines Azure-specific credential fields.
func (*AzureCredentials) BuildWhoamiInfo ¶ added in v1.199.0
func (c *AzureCredentials) BuildWhoamiInfo(info *WhoamiInfo)
BuildWhoamiInfo implements ICredentials for AzureCredentials.
func (*AzureCredentials) GetExpiration ¶ added in v1.199.0
func (c *AzureCredentials) GetExpiration() (*time.Time, error)
GetExpiration implements ICredentials for AzureCredentials.
func (*AzureCredentials) IsExpired ¶ added in v1.199.0
func (c *AzureCredentials) IsExpired() bool
IsExpired returns true if the credentials are expired. This implements the ICredentials interface.
func (*AzureCredentials) Validate ¶ added in v1.199.0
func (c *AzureCredentials) Validate(ctx context.Context) (*ValidationInfo, error)
Validate validates Azure credentials by calling Azure Resource Manager API. Returns validation info including subscription name, tenant ID, and expiration.
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 CredentialField ¶ added in v1.203.0
type CredentialField struct {
Name string // Field identifier (e.g., "access_key_id").
Title string // Display title (e.g., "AWS Access Key ID").
Description string // Help text.
Required bool // Must be non-empty.
Secret bool // Mask input (password mode).
Default string // Pre-populated value.
Validator func(string) error // Optional validation function.
}
CredentialField describes a single credential input field.
type CredentialPromptFunc ¶ added in v1.203.0
type CredentialPromptFunc func(spec CredentialPromptSpec) (map[string]string, error)
CredentialPromptFunc is the generic prompting interface. It takes a specification of what credentials to collect and returns them as a map. Each identity type can define its own fields, and the prompting UI is generic.
type CredentialPromptResult ¶ added in v1.203.0
CredentialPromptResult holds the result of a credential prompt operation.
func (*CredentialPromptResult) Get ¶ added in v1.203.0
func (r *CredentialPromptResult) Get(name string) string
Get returns the value for a field, or empty string if not found.
type CredentialPromptSpec ¶ added in v1.203.0
type CredentialPromptSpec struct {
IdentityName string // Name of the identity requiring credentials.
CloudType string // Cloud provider: "aws", "azure", "gcp".
Fields []CredentialField // Fields to prompt for.
}
CredentialPromptSpec defines what credentials to prompt for.
type CredentialStore ¶
type CredentialStore interface {
// Store stores credentials for the given alias within the specified realm.
// The realm provides credential isolation - the same alias in different realms
// refers to completely separate credentials.
Store(alias string, creds ICredentials, realm string) error
// Retrieve retrieves credentials for the given alias within the specified realm.
// Returns error if no credentials exist for the alias in the given realm.
Retrieve(alias string, realm string) (ICredentials, error)
// Delete deletes credentials for the given alias within the specified realm.
Delete(alias string, realm string) error
// List returns all stored credential aliases within the specified realm.
// Returns only aliases that belong to the given realm.
List(realm string) ([]string, error)
// IsExpired checks if credentials for the given alias are expired within the specified realm.
IsExpired(alias string, realm 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. All methods that operate on credentials require a realm parameter to ensure complete isolation between different repositories or customer environments.
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)
// Paths returns credential files/directories used by this identity.
// Returns empty slice if identity doesn't use filesystem credentials.
// Paths are in addition to provider paths (identities can add more files).
Paths() ([]Path, 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)
// SetRealm sets the credential isolation realm for this identity.
// Called by the auth manager after identity construction to propagate the realm
// to all identities in the authentication chain.
// The realm is used for all credential storage and file operations.
SetRealm(realm string)
}
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) AuthenticateProvider ¶ added in v1.200.0
func (m *MockAuthManager) AuthenticateProvider(ctx context.Context, providerName string) (*WhoamiInfo, error)
AuthenticateProvider mocks base method.
func (*MockAuthManager) EXPECT ¶ added in v1.196.0
func (m *MockAuthManager) EXPECT() *MockAuthManagerMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockAuthManager) ExecuteIdentityIntegrations ¶ added in v1.203.0
func (m *MockAuthManager) ExecuteIdentityIntegrations(ctx context.Context, identityName string) error
ExecuteIdentityIntegrations mocks base method.
func (*MockAuthManager) ExecuteIntegration ¶ added in v1.203.0
func (m *MockAuthManager) ExecuteIntegration(ctx context.Context, integrationName string) error
ExecuteIntegration mocks base method.
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) GetIntegration ¶ added in v1.203.0
func (m *MockAuthManager) GetIntegration(integrationName string) (*schema.Integration, error)
GetIntegration 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) GetRealm ¶ added in v1.206.0
func (m *MockAuthManager) GetRealm() realm.RealmInfo
GetRealm 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, deleteKeychain bool) error
Logout mocks base method.
func (*MockAuthManager) LogoutAll ¶ added in v1.196.0
func (m *MockAuthManager) LogoutAll(ctx context.Context, deleteKeychain bool) error
LogoutAll mocks base method.
func (*MockAuthManager) LogoutProvider ¶ added in v1.196.0
func (m *MockAuthManager) LogoutProvider(ctx context.Context, providerName string, deleteKeychain bool) 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) ResolvePrincipalSetting ¶ added in v1.205.0
func (m *MockAuthManager) ResolvePrincipalSetting(identityName, key string) (any, bool)
ResolvePrincipalSetting mocks base method.
func (*MockAuthManager) ResolveProviderConfig ¶ added in v1.205.0
func (m *MockAuthManager) ResolveProviderConfig(identityName string) (*schema.Provider, bool)
ResolveProviderConfig 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) AuthenticateProvider ¶ added in v1.200.0
func (mr *MockAuthManagerMockRecorder) AuthenticateProvider(ctx, providerName any) *gomock.Call
AuthenticateProvider indicates an expected call of AuthenticateProvider.
func (*MockAuthManagerMockRecorder) ExecuteIdentityIntegrations ¶ added in v1.203.0
func (mr *MockAuthManagerMockRecorder) ExecuteIdentityIntegrations(ctx, identityName any) *gomock.Call
ExecuteIdentityIntegrations indicates an expected call of ExecuteIdentityIntegrations.
func (*MockAuthManagerMockRecorder) ExecuteIntegration ¶ added in v1.203.0
func (mr *MockAuthManagerMockRecorder) ExecuteIntegration(ctx, integrationName any) *gomock.Call
ExecuteIntegration indicates an expected call of ExecuteIntegration.
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) GetIntegration ¶ added in v1.203.0
func (mr *MockAuthManagerMockRecorder) GetIntegration(integrationName any) *gomock.Call
GetIntegration indicates an expected call of GetIntegration.
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) GetRealm ¶ added in v1.206.0
func (mr *MockAuthManagerMockRecorder) GetRealm() *gomock.Call
GetRealm indicates an expected call of GetRealm.
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, deleteKeychain any) *gomock.Call
Logout indicates an expected call of Logout.
func (*MockAuthManagerMockRecorder) LogoutAll ¶ added in v1.196.0
func (mr *MockAuthManagerMockRecorder) LogoutAll(ctx, deleteKeychain any) *gomock.Call
LogoutAll indicates an expected call of LogoutAll.
func (*MockAuthManagerMockRecorder) LogoutProvider ¶ added in v1.196.0
func (mr *MockAuthManagerMockRecorder) LogoutProvider(ctx, providerName, deleteKeychain 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) ResolvePrincipalSetting ¶ added in v1.205.0
func (mr *MockAuthManagerMockRecorder) ResolvePrincipalSetting(identityName, key any) *gomock.Call
ResolvePrincipalSetting indicates an expected call of ResolvePrincipalSetting.
func (*MockAuthManagerMockRecorder) ResolveProviderConfig ¶ added in v1.205.0
func (mr *MockAuthManagerMockRecorder) ResolveProviderConfig(identityName any) *gomock.Call
ResolveProviderConfig indicates an expected call of ResolveProviderConfig.
func (*MockAuthManagerMockRecorder) Validate ¶ added in v1.196.0
func (mr *MockAuthManagerMockRecorder) Validate() *gomock.Call
Validate indicates an expected call of Validate.
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
func (m *MockConsoleAccessProvider) EXPECT() *MockConsoleAccessProviderMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockConsoleAccessProvider) GetConsoleURL ¶ added in v1.196.0
func (m *MockConsoleAccessProvider) GetConsoleURL(ctx context.Context, creds ICredentials, options ConsoleURLOptions) (string, time.Duration, error)
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, arg1 string) error
Delete mocks base method.
func (*MockCredentialStore) EXPECT ¶ added in v1.196.0
func (m *MockCredentialStore) EXPECT() *MockCredentialStoreMockRecorder
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, arg1 string) (bool, error)
IsExpired mocks base method.
func (*MockCredentialStore) List ¶ added in v1.196.0
func (m *MockCredentialStore) List(arg0 string) ([]string, error)
List mocks base method.
func (*MockCredentialStore) Retrieve ¶ added in v1.196.0
func (m *MockCredentialStore) Retrieve(alias, arg1 string) (ICredentials, error)
Retrieve mocks base method.
func (*MockCredentialStore) Store ¶ added in v1.196.0
func (m *MockCredentialStore) Store(alias string, creds ICredentials, arg2 string) 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, arg1 any) *gomock.Call
Delete indicates an expected call of Delete.
func (*MockCredentialStoreMockRecorder) IsExpired ¶ added in v1.196.0
func (mr *MockCredentialStoreMockRecorder) IsExpired(alias, arg1 any) *gomock.Call
IsExpired indicates an expected call of IsExpired.
func (*MockCredentialStoreMockRecorder) List ¶ added in v1.196.0
func (mr *MockCredentialStoreMockRecorder) List(arg0 any) *gomock.Call
List indicates an expected call of List.
func (*MockCredentialStoreMockRecorder) Retrieve ¶ added in v1.196.0
func (mr *MockCredentialStoreMockRecorder) Retrieve(alias, arg1 any) *gomock.Call
Retrieve indicates an expected call of Retrieve.
func (*MockCredentialStoreMockRecorder) Store ¶ added in v1.196.0
func (mr *MockCredentialStoreMockRecorder) Store(alias, creds, arg2 any) *gomock.Call
Store indicates an expected call of Store.
func (*MockCredentialStoreMockRecorder) Type ¶ added in v1.196.0
func (mr *MockCredentialStoreMockRecorder) Type() *gomock.Call
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
func (m *MockICredentials) EXPECT() *MockICredentialsMockRecorder
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.
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
func (m *MockIdentity) EXPECT() *MockIdentityMockRecorder
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) Paths ¶ added in v1.201.0
func (m *MockIdentity) Paths() ([]Path, error)
Paths 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) SetRealm ¶ added in v1.206.0
func (m *MockIdentity) SetRealm(arg0 string)
SetRealm 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) Paths ¶ added in v1.201.0
func (mr *MockIdentityMockRecorder) Paths() *gomock.Call
Paths indicates an expected call of Paths.
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) SetRealm ¶ added in v1.206.0
func (mr *MockIdentityMockRecorder) SetRealm(arg0 any) *gomock.Call
SetRealm indicates an expected call of SetRealm.
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
func (m *MockProvider) EXPECT() *MockProviderMockRecorder
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) Paths ¶ added in v1.201.0
func (m *MockProvider) Paths() ([]Path, error)
Paths 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) SetRealm ¶ added in v1.206.0
func (m *MockProvider) SetRealm(arg0 string)
SetRealm 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) Paths ¶ added in v1.201.0
func (mr *MockProviderMockRecorder) Paths() *gomock.Call
Paths indicates an expected call of Paths.
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) SetRealm ¶ added in v1.206.0
func (mr *MockProviderMockRecorder) SetRealm(arg0 any) *gomock.Call
SetRealm indicates an expected call of SetRealm.
func (*MockProviderMockRecorder) Validate ¶ added in v1.196.0
func (mr *MockProviderMockRecorder) Validate() *gomock.Call
Validate indicates an expected call of Validate.
type MockProvisioner ¶ added in v1.200.0
type MockProvisioner struct {
// contains filtered or unexported fields
}
MockProvisioner is a mock of Provisioner interface.
func NewMockProvisioner ¶ added in v1.200.0
func NewMockProvisioner(ctrl *gomock.Controller) *MockProvisioner
NewMockProvisioner creates a new mock instance.
func (*MockProvisioner) EXPECT ¶ added in v1.200.0
func (m *MockProvisioner) EXPECT() *MockProvisionerMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockProvisioner) ProvisionIdentities ¶ added in v1.200.0
func (m *MockProvisioner) ProvisionIdentities(ctx context.Context, creds ICredentials) (*ProvisioningResult, error)
ProvisionIdentities mocks base method.
type MockProvisionerMockRecorder ¶ added in v1.200.0
type MockProvisionerMockRecorder struct {
// contains filtered or unexported fields
}
MockProvisionerMockRecorder is the mock recorder for MockProvisioner.
func (*MockProvisionerMockRecorder) ProvisionIdentities ¶ added in v1.200.0
func (mr *MockProvisionerMockRecorder) ProvisionIdentities(ctx, creds any) *gomock.Call
ProvisionIdentities indicates an expected call of ProvisionIdentities.
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
func (m *MockValidator) EXPECT() *MockValidatorMockRecorder
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 Path ¶ added in v1.201.0
type Path struct {
// Location is the filesystem path (may contain ~ for home directory).
Location string `json:"location"`
// Type indicates if this is a file or directory.
Type PathType `json:"type"`
// Required indicates if path must exist for provider to function.
// If false, missing paths are optional (provider works without them).
Required bool `json:"required"`
// Purpose describes what this path is used for (helps with debugging/logging).
// Examples: "AWS credentials file", "Azure config directory", "GCP service account key"
Purpose string `json:"purpose"`
// Metadata holds optional provider-specific information.
// Consumers can use this for advanced features without breaking interface.
// Examples:
// - "selinux_label": "system_u:object_r:container_file_t:s0" (future SELinux support)
// - "read_only": "true" (hint that path should be read-only)
// - "mount_target": "/workspace/.aws" (suggested container path)
Metadata map[string]string `json:"metadata,omitempty"`
}
Path represents a credential file or directory used by the provider/identity.
type PathType ¶ added in v1.201.0
type PathType string
PathType indicates what kind of filesystem entity the path represents.
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.
Realm string // Credential isolation realm for file storage.
}
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)
// Paths returns credential files/directories used by this provider.
// Returns empty slice if provider doesn't use filesystem credentials (e.g., GitHub tokens).
// Consumers decide how to use these paths (mount, copy, delete, etc.).
Paths() ([]Path, 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
// SetRealm sets the credential isolation realm for this provider.
// Called by the auth manager after provider construction to propagate the realm
// to all providers. The realm is used for credential file paths.
SetRealm(realm string)
}
Provider defines the interface that all authentication providers must implement.
type Provisioner ¶ added in v1.200.0
type Provisioner interface {
// ProvisionIdentities provisions identities from the external source.
// Returns provisioned identities and metadata, or error if provisioning fails.
// Implementations should be non-fatal - errors are logged but don't block authentication.
ProvisionIdentities(ctx context.Context, creds ICredentials) (*ProvisioningResult, error)
}
Provisioner is an optional interface that providers can implement to auto-provision identities from external sources (e.g., AWS SSO permission sets). Provisioning is run after successful provider authentication and is non-fatal.
type ProvisioningCounts ¶ added in v1.200.0
type ProvisioningCounts = provisioning.Counts
ProvisioningCounts is an alias for provisioning.Counts.
type ProvisioningMetadata ¶ added in v1.200.0
type ProvisioningMetadata = provisioning.Metadata
ProvisioningMetadata is an alias for provisioning.Metadata.
type ProvisioningResult ¶ added in v1.200.0
type ProvisioningResult = provisioning.Result
ProvisioningResult is an alias for provisioning.Result. This allows the manager to use types.ProvisioningResult while the actual implementation lives in pkg/auth/provisioning.
type ProvisioningWriter ¶ added in v1.200.0
type ProvisioningWriter = provisioning.Writer
ProvisioningWriter is an alias for provisioning.Writer.
func NewProvisioningWriter ¶ added in v1.200.0
func NewProvisioningWriter() (*ProvisioningWriter, error)
NewProvisioningWriter creates a new provisioning writer.
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 {
// Realm is the credential isolation boundary for this authentication context.
// Credentials from different realms are completely isolated.
Realm string `json:"realm,omitempty"`
// RealmSource indicates how the realm was determined: "env", "config", or "auto".
RealmSource string `json:"realm_source,omitempty"`
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"`
// Paths contains combined paths from provider and identity chains.
// Later paths override earlier ones if Location matches.
Paths []Path `json:"paths,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. The realm is taken from w.Realm to ensure credentials are retrieved from the correct isolation boundary.