Documentation
¶
Overview ¶
Package secrets provides named credential sources and a value type that redacts formatted output.
Design ¶
Secret redacts fmt, text and JSON serialization; Bytes provides explicit access to the value. Static, Env, Dir and Chain providers support injected values, normalized environment names, bounded rooted files and fallback. Dir uses os.Root so names cannot escape its configured directory.
Redaction reduces accidental disclosure through formatting; it does not protect values after explicit extraction or encrypt memory. storage/crypt provides sealing for selected persisted values.
References ¶
- Decision record 0011: https://github.com/deploymenttheory/go-apple-dm/blob/main/docs/research/decisions/0011-secrets-provider.md
- Decision record 0013: https://github.com/deploymenttheory/go-apple-dm/blob/main/docs/research/decisions/0013-secrets-at-rest.md
- Threat model: https://github.com/deploymenttheory/go-apple-dm/blob/main/docs/security/threat-model.md (Push credential exposure row)
- Apple: https://developer.apple.com/documentation/devicemanagement/managing-certificates-for-device-management-services-and-devices
Index ¶
Constants ¶
const Redacted = "[redacted]"
Redacted is what a Secret prints as.
Variables ¶
var ErrName = errors.New("secrets: invalid name")
ErrName is returned for names a provider cannot map safely.
var ErrNotFound = errors.New("secrets: not found")
ErrNotFound is returned when a provider has no value for a name.
Functions ¶
This section is empty.
Types ¶
type Dir ¶
type Dir struct {
// contains filtered or unexported fields
}
Dir reads each secret from a file named after it inside one directory, the layout Docker and Kubernetes secrets mount. Trailing newlines are trimmed. Names must not contain path separators.
type Env ¶
type Env struct {
Prefix string
// Lookup defaults to os.LookupEnv.
Lookup func(string) (string, bool)
}
Env reads secrets from environment variables. The name is upper-cased with dots and dashes replaced by underscores, then prefixed.
type Secret ¶
type Secret struct {
// contains filtered or unexported fields
}
Secret holds a credential. Its String, GoString, Format, MarshalJSON, and MarshalText outputs are always Redacted; use Bytes to get the value.
func (Secret) MarshalJSON ¶
MarshalJSON implements json.Marshaler with the constant.
func (Secret) MarshalText ¶
MarshalText implements encoding.TextMarshaler with the constant.