Documentation
¶
Index ¶
- Constants
- Variables
- func EmptyRealmKeyIsUnambiguous(alias string) bool
- func KeyringType(config *schema.AuthConfig) string
- func NewCredentialStore() types.CredentialStoredeprecated
- func NewCredentialStoreWithConfig(authConfig *schema.AuthConfig) types.CredentialStore
- func NewKeyringAuthStore() types.CredentialStore
- func OpenKeyring(config *schema.AuthConfig) (keyring.Keyring, error)
- func RegisterCodec(tag string, constructor CredentialConstructor) error
- type AmbiguousLegacyRealmDeleter
- type AmbiguousLegacyRealmEntry
- type AmbiguousLegacyRealmStore
- type CodecRegistry
- type ConfigDigestStore
- type CredentialConstructor
- type ExternalConfigDigest
- type LegacyRealmOwner
Constants ¶
const ( // KeyringUser is the "account" used to store credentials in the keyring. Here we use atmos-auth to provide a consistent way to search for atmos credentials. KeyringUser = "atmos-auth" // KeyringRealmPrefix is the prefix used for realm-scoped keyring keys. KeyringRealmPrefix = "atmos" // KeyringSeparator is the separator used between key components. // Uses underscore instead of colon for Windows compatibility (colons not allowed in filenames). KeyringSeparator = "_" // KeyringRealmAliasSeparator separates the realm from the alias in realm-scoped keys. // Realms cannot contain "__" or end with "_" (see realm.Validate), so the first "__" // after the prefix always ends the realm, whatever the alias contains. KeyringRealmAliasSeparator = "__" )
const KeyringConfigDigestPrefix = "atmos-config-digest"
KeyringConfigDigestPrefix prefixes the keys of configuration digest records kept for credentials an identity persists outside this store (for example AWS session credentials in the identity's credentials file). It differs from KeyringRealmPrefix + KeyringSeparator, so List never reports these records as credential aliases. The persistent backends (system and file) keep the records in files named after this key instead of in the keyring (see config_digest_file.go); only the memory backend stores them under it.
const (
// KeyringDirPermissions is the default permission for the keyring directory (owner-only).
KeyringDirPermissions = 0o700
)
Variables ¶
var ( // ErrUnsupportedCredentialType indicates the credential type is not supported. ErrUnsupportedCredentialType = errors.New("unsupported credential type") // ErrUnknownCredentialType indicates an unknown credential type was encountered. ErrUnknownCredentialType = errors.New("unknown credential type") // ErrCredentialsNotFound indicates credentials were not found for the given key. ErrCredentialsNotFound = errors.New("credentials not found") // ErrDataNotFound indicates data was not found for the given key. ErrDataNotFound = errors.New("data not found") // ErrPasswordRequired indicates a password is required but not provided. ErrPasswordRequired = errors.New("keyring password required") // ErrPasswordTooShort indicates the password does not meet the minimum length requirement. ErrPasswordTooShort = errors.New("password must be at least 8 characters") )
var ErrCredentialStore = errors.New("credential store")
ErrCredentialStore is the static sentinel for credential-store failures.
var ErrListNotSupported = errors.New("listing credentials is not supported with keyring backend")
ErrListNotSupported indicates that listing credentials is not supported with keyring backend.
var ErrNotSupported = errors.New("not supported")
ErrNotSupported indicates an unsupported operation for this backend.
Functions ¶
func EmptyRealmKeyIsUnambiguous ¶
EmptyRealmKeyIsUnambiguous reports whether the empty-realm (pre-realm) key "atmos_<alias>" can only belong to alias. An alias containing "_" shares its key with a realm-scoped entry of another realm ("prod_admin" is realm "prod" + "admin" in the previous layout, and "prod__admin" is realm "prod" + "admin" in the current one), so realm-scoped callers must not delete that empty-realm key as their own legacy entry.
func KeyringType ¶
func KeyringType(config *schema.AuthConfig) string
KeyringType reports the selected backend including the existing environment override.
func NewCredentialStore
deprecated
func NewCredentialStore() types.CredentialStore
NewCredentialStore creates a new credential store instance based on configuration. It selects the appropriate backend (system, file, or memory) based on: 1. ATMOS_KEYRING_TYPE environment variable (highest priority). 2. AuthConfig.Keyring.Type configuration. 3. Default to "system" for backward compatibility.
Deprecated: this no-argument form cannot honor auth.keyring.type from atmos.yaml because it passes a nil config to NewCredentialStoreWithConfig. Production code MUST use NewCredentialStoreWithConfig(authConfig) so the configured keyring backend is selected (see issue #2544). This form remains only for tests and other call sites that genuinely have no auth config.
func NewCredentialStoreWithConfig ¶ added in v1.196.0
func NewCredentialStoreWithConfig(authConfig *schema.AuthConfig) types.CredentialStore
NewCredentialStoreWithConfig creates a credential store with explicit configuration.
func NewKeyringAuthStore ¶
func NewKeyringAuthStore() types.CredentialStore
NewKeyringAuthStore creates a new system keyring-based auth store (for backward compatibility). Deprecated: Use NewCredentialStore() instead.
func OpenKeyring ¶
func OpenKeyring(config *schema.AuthConfig) (keyring.Keyring, error)
OpenKeyring opens the configured auth backend for private provider sessions. Unlike optional credential caching, durable session writes must fail visibly when the requested backend cannot be opened; no fallback to noop is allowed.
func RegisterCodec ¶
func RegisterCodec(tag string, constructor CredentialConstructor) error
RegisterCodec extends credential persistence without replacing a built-in codec.
Types ¶
type AmbiguousLegacyRealmDeleter ¶
type AmbiguousLegacyRealmDeleter interface {
// DeleteAmbiguousLegacyRealmEntry deletes the ambiguous previous-layout entry of alias in
// realm, whatever it holds, and describes it (Key and OtherOwners; Credentials is nil). It
// returns nil when there is no such entry. Keys that are also current-layout keys of another
// realm (they contain "__") are never deleted.
DeleteAmbiguousLegacyRealmEntry(alias, realm string) (*AmbiguousLegacyRealmEntry, error)
}
AmbiguousLegacyRealmDeleter is implemented by credential stores that can delete the ambiguous previous-layout keyring entry of an alias in a realm. Delete never removes such an entry, because it may belong to another realm and alias split; an explicit keychain logout does, because older versions treated the entry as the alias's own key and deleted it at logout, and keeping it would let a later login offer to revive the credentials the user just deleted.
type AmbiguousLegacyRealmEntry ¶
type AmbiguousLegacyRealmEntry struct {
// Key is the previous-layout keyring key, for example "atmos_acme_prod_admin".
Key string
// Credentials are the decoded credentials stored under Key.
Credentials types.ICredentials
// OtherOwners lists the other realm and alias pairs that older versions also stored
// under Key, so a caller can tell the user who else the entry could belong to.
OtherOwners []LegacyRealmOwner
}
AmbiguousLegacyRealmEntry describes a previous-layout keyring entry that may hold the credentials of an alias in a realm but could also have been written for another realm and alias split of the same key. It never carries the raw entry, only the decoded credentials.
type AmbiguousLegacyRealmStore ¶
type AmbiguousLegacyRealmStore interface {
// FindAmbiguousLegacyRealmEntry returns the ambiguous previous-layout entry for alias in
// realm, or nil when there is nothing to adopt: the current key exists, the legacy key is
// unambiguous (Retrieve migrates those itself), absent, or does not decode.
FindAmbiguousLegacyRealmEntry(alias, realm string) (*AmbiguousLegacyRealmEntry, error)
// AdoptAmbiguousLegacyRealmEntry copies the ambiguous previous-layout entry to the current
// key of alias in realm, unless the current key already exists, and then deletes the legacy
// key. Call it only after the user confirmed the entry belongs to alias in realm.
AdoptAmbiguousLegacyRealmEntry(alias, realm string) error
}
AmbiguousLegacyRealmStore is implemented by credential stores that can find and adopt previous-layout keyring entries whose key is ambiguous. Retrieve never reads such entries (see legacyKeyIsUnambiguous) because they might belong to another realm; a caller that can ask the user whether the entry is theirs uses this interface instead.
type CodecRegistry ¶
type CodecRegistry struct {
// contains filtered or unexported fields
}
CodecRegistry maps persisted envelope tags to credential types. Registering a new type never changes the encoding of existing sessions.
func NewCodecRegistry ¶
func NewCodecRegistry() *CodecRegistry
NewCodecRegistry registers the legacy JSON representations used by existing sessions.
func (*CodecRegistry) Marshal ¶
func (r *CodecRegistry) Marshal(creds types.ICredentials) (string, []byte, error)
Marshal encodes credentials using their registered, stable envelope tag.
func (*CodecRegistry) Register ¶
func (r *CodecRegistry) Register(tag string, constructor CredentialConstructor) error
Register binds a unique persisted tag to a unique concrete credential type. Constructors must return a fresh pointer of the same type on every call.
func (*CodecRegistry) Unmarshal ¶
func (r *CodecRegistry) Unmarshal(tag string, raw []byte) (types.ICredentials, error)
Unmarshal decodes a stored envelope. Unknown tags fail without interpreting its payload.
type ConfigDigestStore ¶
type ConfigDigestStore interface {
// SupportsConfigDigests reports whether digests written now can be read back later.
SupportsConfigDigests() bool
// StoreWithConfigDigest stores credentials like Store, together with digest.
StoreWithConfigDigest(alias string, creds types.ICredentials, realm, digest string) error
// RetrieveWithConfigDigest retrieves credentials like Retrieve, together with the digest
// they were stored with. Entries written without one (by older versions) return "".
RetrieveWithConfigDigest(alias, realm string) (types.ICredentials, string, error)
// StoreExternalConfigDigest records the digest of credentials persisted outside the store.
StoreExternalConfigDigest(alias, realm string, record ExternalConfigDigest) error
// RetrieveExternalConfigDigest returns the record written by StoreExternalConfigDigest.
RetrieveExternalConfigDigest(alias, realm string) (ExternalConfigDigest, error)
// DeleteExternalConfigDigest removes the record written by StoreExternalConfigDigest. It is
// idempotent. Delete also removes it; logout calls this directly because it removes the
// credentials the record describes even when it keeps the keyring entry.
DeleteExternalConfigDigest(alias, realm string) error
}
ConfigDigestStore is implemented by credential stores that can persist a digest of the effective configuration that produced a credential, so a later process can refuse to reuse credentials written for a different configuration under the same alias. The digest is computed by the caller over non-secret fields only; the store treats it as opaque.
type CredentialConstructor ¶
type CredentialConstructor func() types.ICredentials
CredentialConstructor returns a fresh non-nil pointer for JSON decoding.
type ExternalConfigDigest ¶
type ExternalConfigDigest struct {
// Digest is the SHA-256 of the chain step's non-secret effective configuration.
Digest string `json:"digest"`
// Expiration is the credentials' expiration in RFC 3339 UTC, or empty when they have none.
Expiration string `json:"expiration,omitempty"`
// CredentialID is the non-secret identifier of the credential set (the AWS access key ID of
// session credentials), or empty for credentials without one.
CredentialID string `json:"credential_id,omitempty"`
}
ExternalConfigDigest records which effective configuration produced credentials that an identity persisted outside the credential store. Expiration and CredentialID bind the record to that exact credential set: credentials rewritten by anything else (an older Atmos, another tool, another principal) carry a different expiration or access key ID and no longer match. No field is secret.
type LegacyRealmOwner ¶
type LegacyRealmOwner struct {
// Realm is the credential realm.
Realm string
// Alias is the identity or provider name.
Alias string
}
LegacyRealmOwner is a realm and alias pair whose previous-layout keyring key ("atmos_<realm>_<alias>") is a given key.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package credtest isolates tests from the operating-system keychain.
|
Package credtest isolates tests from the operating-system keychain. |
|
Package prompt provides shared secret input forms for auth identities.
|
Package prompt provides shared secret input forms for auth identities. |