realm

package
v1.235.0 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: Apache-2.0 Imports: 6 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 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

View Source
const (
	// SourceConfigPath is the realm source pkg/config records when no realm is
	// configured and it derives one from a hash of the atmos.yaml path.
	SourceConfigPath = "config-path"

	// SourceDefault is the realm source pkg/config records when no realm is
	// configured and there is no atmos.yaml path to derive one from.
	SourceDefault = "default"
)
View Source
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 not explicitly configured (empty realm for backward compatibility).
	SourceAuto = "auto"

	// MaxLength is the maximum allowed length for a realm value.
	MaxLength = 64

	// AutoValueLength is the length of the realm Atmos derives from the atmos.yaml path when no
	// realm is configured: the first 8 bytes of a SHA-256, as lowercase hex (pkg/config/auth_realm.go).
	AutoValueLength = 16
)

Variables

This section is empty.

Functions

func HasAutoValueFormat

func HasAutoValueFormat(value string) bool

HasAutoValueFormat reports whether value has the exact format of the realm Atmos derives from the atmos.yaml path when no realm is configured: AutoValueLength lowercase hexadecimal characters. Such a realm never contains "_". Callers that only see the realm string use this to recognize the auto realm; a configured realm can have the same format, so callers that know the configured realm must exclude it themselves.

func IsExplicit

func IsExplicit(info RealmInfo, configSource string) bool

IsExplicit reports whether info is a realm the user configured explicitly.

When no realm is configured, pkg/config stores a derived value in auth.realm (a hash of the atmos.yaml path, or "default") and records how it got it in AuthConfig.RealmSource. GetRealm then reports that value with SourceConfig, so configSource (AuthConfig.RealmSource) is what tells a derived realm from one set in atmos.yaml. A realm from ATMOS_AUTH_REALM is always explicit, and an empty realm never is.

func IsExplicitSource

func IsExplicitSource(source string) bool

IsExplicitSource reports whether a realm with this source was configured explicitly, through ATMOS_AUTH_REALM or auth.realm. The sources of a derived realm (SourceAuto, SourceConfigPath and SourceDefault) are not explicit. An empty source counts as explicit: it means the realm was set directly on the auth configuration instead of being resolved by pkg/config.

func Validate

func Validate(input string) error

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

func GetRealm(configRealm, cliConfigPath string) (RealmInfo, error)

GetRealm computes the authentication realm with the following precedence:

  1. ATMOS_AUTH_REALM environment variable (highest priority)
  2. configRealm from atmos.yaml auth.realm configuration
  3. Empty realm — legacy credential paths are used without a realm subdirectory.

Returns an error if an explicit realm value (env var or config) contains invalid characters.

func (RealmInfo) SourceDescription

func (r RealmInfo) SourceDescription(cliConfigPath string) string

SourceDescription returns a human-readable description of where the realm came from.

Jump to

Keyboard shortcuts

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