Documentation
¶
Overview ¶
Package realm provides credential realm computation and validation for authentication isolation. A realm defines an isolated credential namespace, preventing collisions when the same identity names are used across different repositories or customer environments.
Index ¶
Constants ¶
const ( // EnvVarName is the environment variable name for overriding the auth realm. EnvVarName = "ATMOS_AUTH_REALM" // SourceEnv indicates the realm was set via environment variable. SourceEnv = "env" // SourceConfig indicates the realm was set via atmos.yaml configuration. SourceConfig = "config" // SourceAuto indicates the realm was automatically computed from the config path. SourceAuto = "auto" // MaxLength is the maximum allowed length for a realm value. MaxLength = 64 )
Variables ¶
This section is empty.
Functions ¶
func Validate ¶
Validate checks that a realm value contains only allowed characters and follows all rules.
Validation rules:
- Must contain only lowercase letters (a-z), digits (0-9), hyphens (-), and underscores (_)
- Must not be empty
- Must not exceed MaxLength (64) characters
- Must not start or end with hyphen or underscore
- Must not contain consecutive hyphens or underscores
- Must not contain path traversal sequences (/, \, ..)
Returns an error describing the validation failure, or nil if valid.
Types ¶
type RealmInfo ¶
type RealmInfo struct {
// Value is the realm identifier used for credential isolation.
Value string
// Source indicates how the realm was determined: "env", "config", or "auto".
Source string
}
RealmInfo contains the computed realm value and its source.
func GetRealm ¶
GetRealm computes the authentication realm with the following precedence:
- ATMOS_AUTH_REALM environment variable (highest priority)
- configRealm from atmos.yaml auth.realm configuration
- SHA256 hash of cliConfigPath (first 8 characters) as automatic default
Returns an error if an explicit realm value (env var or config) contains invalid characters. Auto-generated realms from path hashes are always valid since they only contain hex characters.
func (RealmInfo) SourceDescription ¶
SourceDescription returns a human-readable description of where the realm came from.