Documentation
¶
Overview ¶
Package secrets supplies credentials (push keys, DEP tokens, challenge keys) to the library without letting them leak into logs, errors, or JSON: a Secret that redacts itself wherever it is formatted and Providers that read from a static map, the environment, or a directory of files.
Why ¶
An MDM server holds the keys to every device it manages, and the commonest way they escape is a log line or an error message. Phase 3 of the plan of record introduces this package (decision record 0011) so every credential the library touches is a Secret, which prints as Redacted in fmt, slog, and JSON, and is fetched by name from a Provider the deployment chooses: Static for tests, Env for twelve-factor deployments, Dir for the file layout Docker and Kubernetes mount, and Chain to combine them. Dir is os.Root-scoped so a name cannot escape the directory.
The package supplies secrets; it does not seal them. Encryption of stored per-device secrets under a key from a Provider is storage/crypt.
References ¶
- Decision record 0011: docs/research/decisions/0011-secrets-provider.md
- Decision record 0013: docs/research/decisions/0013-secrets-at-rest.md
- Plan of record: docs/research/implementation_plan.md (phase 3)
- Threat model: 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.