Documentation
¶
Overview ¶
Package inventory resolves the entities a writ policy matches against: users (SCIM-shaped, RFC 7643) and hosts (name + labels + optional account list). The interface is the pluggability seam — today's implementation is a static file, later ones may be databases or live SCIM stores, and implementations are free to synthesize hosts (e.g. pattern-derived labels for short-lived VMs).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Inventory ¶
type Inventory interface {
// LookupUser resolves an OIDC-bound identity to a user by comparing
// it byte-for-byte against the configured SCIM identity attribute
// (default userName).
LookupUser(ctx context.Context, identity string) (*eval.User, error)
// LookupHost resolves a requested host name. Callers must pass the
// name through il.HostName first; implementations may synthesize a
// host for names they can derive attributes for.
LookupHost(ctx context.Context, name string) (*ResolvedHost, error)
}
Inventory looks up users and hosts at evaluation time.
A (nil, nil) return means "no such entity" — a structural non-match that the evaluator turns into a 403, not an error. A non-nil error means the lookup itself failed and the evaluation must fail closed (500).
type PrincipalMode ¶ added in v0.23.0
type PrincipalMode string
PrincipalMode selects how an allowed account@host tuple is represented in an issued SSH certificate.
const ( // AccountNamePrincipals places the literal requested account name in the // certificate. It is compatible with ordinary OpenSSH CA configuration but // is not destination-bound. AccountNamePrincipals PrincipalMode = "account-name" // EpithetPrincipalV1 derives a destination-bound v1 principal from the // principal domain and requested account name. EpithetPrincipalV1 PrincipalMode = principal.SchemeV1 )
func (PrincipalMode) Effective ¶ added in v0.23.0
func (m PrincipalMode) Effective() PrincipalMode
Effective returns the concrete mode represented by m.
func (PrincipalMode) Validate ¶ added in v0.23.0
func (m PrincipalMode) Validate() error
Validate rejects unknown non-empty principal modes. Empty is the zero-value spelling of AccountNamePrincipals for compatibility with custom inventory implementations constructed in Go.
type ResolvedHost ¶ added in v0.23.0
type ResolvedHost struct {
Policy eval.Host
PrincipalMode PrincipalMode
Domain principal.Domain
}
ResolvedHost carries both the authorization resource consumed by Writ and issuance metadata that must remain outside the pure policy model. For a shared named domain, Policy.Name is the domain rather than the requested hostname because the resulting credential is portable across every member.
type Static ¶
type Static struct {
// contains filtered or unexported fields
}
Static is a file-backed inventory: SCIM-shaped users and hosts loaded once at startup. Reload is a process restart, like the policy itself.
Host entries come in two forms. An exact entry (`name:`) is one registered host. A pattern entry (`pattern:`) uses the same DNS-label-aware hostname patterns as Writ host selectors. Account-name entries adopt the requested name; destination-bound named domains expose that domain as the Writ resource so policy cannot claim per-member isolation. Patterns are the escape hatch for fleets of short-lived hosts (VM pools, CI runners) that follow a naming pattern but cannot be enumerated in a file.
func NewStatic ¶
func NewStatic(paths []string, options ...StaticOption) (*Static, error)
NewStatic loads an inventory from one or more YAML files. Files concatenate; a duplicate userName or exact host name across the set is a load error. Decoding is strict — an unknown field is an error, not a silently ignored typo.
func (*Static) LookupHost ¶
LookupHost implements Inventory: exact entries first, then pattern entries in file order, first match wins.
type StaticOption ¶ added in v0.23.0
type StaticOption func(*staticOptions) error
StaticOption configures static inventory loading.
func WithDefaultPrincipalMode ¶ added in v0.23.0
func WithDefaultPrincipalMode(mode PrincipalMode) StaticOption
WithDefaultPrincipalMode sets the mode inherited by host entries that omit principal-mode. The default is AccountNamePrincipals.