Documentation
¶
Overview ¶
Package secrets resolves provider-qualified secret references.
It deliberately provides a closed, explicitly constructed registry. It is an internal routing boundary, not a plugin or provider-extension API.
Index ¶
Examples ¶
Constants ¶
const ( // MaxPlaintextSize bounds one decrypted JSON document. MaxPlaintextSize int64 = 1 << 20 )
Variables ¶
This section is empty.
Functions ¶
func SnapshotStores ¶
SnapshotStores returns a deterministic ciphertext-only identity for a strongest-to-weakest candidate list. Missing candidates participate so a later appearance changes the snapshot. It retains no ciphertext or decoded values.
Types ¶
type AgeProvider ¶
type AgeProvider struct {
// contains filtered or unexported fields
}
AgeProvider decrypts JSON stores with the external age command. It retains no plaintext or decoded-document cache.
func NewAgeProvider ¶
func NewAgeProvider(options AgeProviderOptions) (*AgeProvider, error)
NewAgeProvider validates effective age configuration. Identity paths must be absolute; their contents are never opened or inspected by Wirecmd.
func (*AgeProvider) Resolve ¶
func (p *AgeProvider) Resolve(ctx context.Context, _ Scope, locators []string) (BatchResult, error)
Resolve decrypts each needed store at most once and applies first-store-wins precedence for each requested locator.
func (*AgeProvider) Scheme ¶
func (*AgeProvider) Scheme() string
func (*AgeProvider) ValidateLocator ¶
func (*AgeProvider) ValidateLocator(locator string) error
type AgeProviderOptions ¶
type AgeProviderOptions struct {
Command string
Identities []string
Stores []Store
Timeout time.Duration
MaxPlaintext int64
Snapshot *StoreSnapshot
}
AgeProviderOptions defines the fixed age command and effective store inputs for one configured scope. Command is primarily injectable for tests; normal construction leaves it empty to use age from PATH.
type BatchResult ¶
BatchResult is the result of resolving one provider's deduplicated locators. A locator appears in exactly one of Values or Missing.
type Code ¶
type Code string
Code classifies a secret-resolution failure without requiring callers to parse an error string.
const ( CodeInvalidReference Code = "invalid_secret_reference" CodeUnknownProvider Code = "unknown_secret_provider" CodeDuplicateProvider Code = "duplicate_secret_provider" CodeProviderInvalid Code = "secret_provider_invalid" CodeProviderFailed Code = "secret_provider_failed" CodeAgeVersionUnsupported Code = "age_version_unsupported" CodeAgeDecryptionTimeout Code = "age_decryption_timeout" CodeAgeDecryptionFailed Code = "age_decryption_failed" CodeSecretStoreInvalid Code = "secret_store_invalid" )
type EnvProvider ¶
type EnvProvider struct {
// contains filtered or unexported fields
}
EnvProvider resolves environment values through an injected lookup function. The function must preserve the difference between an unset variable and an explicitly empty variable, as os.LookupEnv does.
func NewEnvProvider ¶
func NewEnvProvider(lookup func(string) (string, bool)) (*EnvProvider, error)
NewEnvProvider constructs an env provider. A nil lookup is invalid because it would make unset values indistinguishable from empty values.
func (*EnvProvider) Resolve ¶
func (p *EnvProvider) Resolve(_ context.Context, _ Scope, locators []string) (BatchResult, error)
func (*EnvProvider) Scheme ¶
func (*EnvProvider) Scheme() string
func (*EnvProvider) ValidateLocator ¶
func (*EnvProvider) ValidateLocator(locator string) error
type Error ¶
Error is a safe, structured secret-resolution error. Message never contains provider stderr, plaintext, or identity contents. Missing contains requested locators only, never their resolved values.
type Provider ¶
type Provider interface {
Scheme() string
ValidateLocator(string) error
Resolve(context.Context, Scope, []string) (BatchResult, error)
}
Provider resolves opaque locators for one normalized scheme. Provider implementations own their locator grammar and never receive other schemes.
type Reference ¶
Reference is a canonical provider-qualified secret reference. It is comparable so callers can use it as a map key without carrying plaintext.
func ParseReference ¶
ParseReference validates provider-independent SCHEME://LOCATOR syntax and returns its canonical representation. A Registry additionally verifies that the scheme exists and applies the provider's locator grammar.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry holds the fixed provider set selected by the CLI or daemon.
func NewRegistry ¶
NewRegistry constructs a closed registry. Schemes are normalized to lower case and duplicate registrations are rejected.
func (*Registry) Resolve ¶
func (r *Registry) Resolve(ctx context.Context, scope Scope, references []Reference) (map[Reference]string, error)
Resolve batches references by provider in deterministic scheme order. It validates References again so manually constructed values cannot bypass a provider's locator rules.
type Scope ¶
type Scope string
Scope identifies the lifecycle context for one batch of secret resolution. The registry does not interpret it; callers keep separate scopes separate.
type Store ¶
Store is one encrypted age document. Stores are evaluated in the order supplied to NewAgeProvider, from strongest to weakest precedence.
type StoreSnapshot ¶
type StoreSnapshot struct {
// contains filtered or unexported fields
}
StoreSnapshot binds a candidate-list identity to the exact ciphertext bytes that will be decrypted. It is operation-local and must not be retained as a daemon cache value.
func CaptureStores ¶
func CaptureStores(stores []Store) (*StoreSnapshot, error)
CaptureStores safely reads each candidate once. The returned ciphertext is consumed by AgeProvider so cache identity and decryption cannot observe different file versions.
func (*StoreSnapshot) Identity ¶
func (s *StoreSnapshot) Identity() string
Identity returns the ciphertext-only deterministic snapshot identity.