Documentation
¶
Overview ¶
Package inventory owns host facts and static loading. The static loader also implements the independent directory.Directory user lookup interface.
Index ¶
- Variables
- func DecodeYAML(data []byte, dst any) error
- func RandomSecret() (string, error)
- type AuditEvent
- type EnrollmentToken
- type Host
- type HostRecord
- type Hosts
- type Managed
- func (m *Managed) Audit() ([]AuditEvent, error)
- func (m *Managed) Change(actor, action, id string, revision uint64, p *Proposal) (*HostRecord, error)
- func (m *Managed) Close() error
- func (m *Managed) CreateToken(actor string, lifetime time.Duration) (EnrollmentToken, error)
- func (m *Managed) Enroll(p Proposal, token string) (*HostRecord, error)
- func (m *Managed) Get(id string) (*HostRecord, error)
- func (m *Managed) Health() error
- func (m *Managed) List() ([]HostRecord, error)
- func (m *Managed) LookupHost(ctx context.Context, name string) (*ResolvedHost, string, error)
- func (m *Managed) RevokeToken(actor, id string) error
- func (m *Managed) Tokens() ([]EnrollmentToken, error)
- type PrincipalMode
- type Proposal
- type ResolvedHost
- type Static
- func (s *Static) DirectoryRevision() string
- func (s *Static) InventoryRevision() string
- func (s *Static) LookupHost(_ context.Context, name string) (*ResolvedHost, string, error)
- func (s *Static) LookupUser(_ context.Context, id string) (*directory.User, error)
- func (s *Static) Records() []HostRecord
- type StaticOption
Constants ¶
This section is empty.
Variables ¶
var ( ErrStorage = errors.New("managed inventory storage unavailable") ErrConflict = errors.New("inventory conflict") ErrNotFound = errors.New("inventory record not found") ErrToken = errors.New("invalid, expired, revoked, or used enrollment token") ErrRevision = errors.New("record changed; reload before retrying") )
Functions ¶
func DecodeYAML ¶ added in v0.31.0
func RandomSecret ¶ added in v0.31.0
Types ¶
type AuditEvent ¶ added in v0.31.0
type EnrollmentToken ¶ added in v0.31.0
type HostRecord ¶ added in v0.31.0
type HostRecord struct {
SourceFile string `yaml:"-" json:"source-file,omitempty"`
Pattern string `yaml:"-" json:"pattern,omitempty"`
ID string `yaml:"id" json:"id"`
Revision uint64 `yaml:"revision" json:"revision"`
Status string `yaml:"status" json:"status"`
Proposal Proposal `yaml:"host" json:"host"`
CreatedAt time.Time `yaml:"created-at" json:"created-at"`
UpdatedAt time.Time `yaml:"updated-at" json:"updated-at"`
Source string `yaml:"-" json:"source,omitempty"`
ShadowedNames []string `yaml:"-" json:"shadowed-names,omitempty"`
}
type Hosts ¶
Hosts resolves machines independently of the user directory. LookupHost returns the host and the revision of the inventory used to resolve it from one coherent read. A missing host returns nil with a nonempty revision; lookup failures return an error.
type Managed ¶ added in v0.31.0
type Managed struct {
// contains filtered or unexported fields
}
Managed loads item files once, then resolves names entirely through indexes. Mutations persist one item before updating its indexes under the write lock. Files are the source of truth; edit them only while the service is stopped.
func OpenManaged ¶ added in v0.31.0
OpenManaged loads the configured dynamic store. Any storage or validation error fails startup; exact static records take precedence after a successful load.
func (*Managed) Audit ¶ added in v0.31.0
func (m *Managed) Audit() ([]AuditEvent, error)
func (*Managed) CreateToken ¶ added in v0.31.0
func (*Managed) Enroll ¶ added in v0.31.0
func (m *Managed) Enroll(p Proposal, token string) (*HostRecord, error)
func (*Managed) Get ¶ added in v0.31.0
func (m *Managed) Get(id string) (*HostRecord, error)
Indexed get is useful to API callers that already have a stable record ID.
func (*Managed) List ¶ added in v0.31.0
func (m *Managed) List() ([]HostRecord, error)
func (*Managed) LookupHost ¶ added in v0.31.0
LookupHost resolves the host and its revision under the same read lock.
func (*Managed) RevokeToken ¶ added in v0.31.0
func (*Managed) Tokens ¶ added in v0.31.0
func (m *Managed) Tokens() ([]EnrollmentToken, error)
type PrincipalMode ¶
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 ¶
func (m PrincipalMode) Effective() PrincipalMode
Effective returns the concrete mode represented by m.
func (PrincipalMode) Validate ¶
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 Proposal ¶ added in v0.31.0
type Proposal struct {
Names []string `yaml:"names" json:"names"`
Labels map[string]string `yaml:"labels" json:"labels"`
Accounts []string `yaml:"accounts" json:"accounts"`
PrincipalMode PrincipalMode `yaml:"principal-mode" json:"principal-mode"`
Domain string `yaml:"domain,omitempty" json:"domain,omitempty"`
}
Proposal is the entire editable authorization record. Admission and ownership are server-owned metadata, never fields a host can approve for itself.
func ParseProposal ¶ added in v0.31.0
ParseProposal distinguishes an explicit null (ungrounded) account set from a missing field, and refuses trailing YAML documents and unknown fields.
func (Proposal) MarshalYAML ¶ added in v0.31.0
MarshalYAML preserves the distinction between unrestricted accounts (null) and an explicit empty account set ([]), both on disk and in the editor.
func (*Proposal) UnmarshalJSON ¶ added in v0.31.0
UnmarshalJSON requires accounts at the input boundary, just as UnmarshalYAML does for editor proposals. Explicit null is unrestricted; [] permits none.
func (*Proposal) UnmarshalYAML ¶ added in v0.31.0
UnmarshalYAML applies the same field-presence contract to on-disk snapshots and editor proposals. Accidentally deleting accounts must not broaden access.
type ResolvedHost ¶
type ResolvedHost struct {
Policy 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.Names contains only the domain rather than individual DNS names 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: directory 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 (`names:`) is one registered host. A pattern entry (`pattern:`) uses the same DNS-label-aware hostname patterns as Writ host selectors. Exact entries expose all their names; pattern 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 missing id, duplicate id/userName, or duplicate exact host name across the set is a load error. All IDs belong to the inventory service's single configured provider/tenant. Decoding is strict — an unknown field is an error, not a silently ignored typo.
func (*Static) DirectoryRevision ¶
func (*Static) InventoryRevision ¶
func (*Static) LookupHost ¶
LookupHost implements Hosts: exact entries first, then pattern entries in file order, first match wins.
func (*Static) LookupUser ¶
LookupUser implements directory.Directory.
func (*Static) Records ¶ added in v0.31.0
func (s *Static) Records() []HostRecord
Records provides read-only source information for inventory administration.
type StaticOption ¶
type StaticOption func(*staticOptions) error
StaticOption configures static inventory loading.
func WithDefaultPrincipalMode ¶
func WithDefaultPrincipalMode(mode PrincipalMode) StaticOption
WithDefaultPrincipalMode sets the mode inherited by host entries that omit principal-mode. The default is AccountNamePrincipals.