Documentation
¶
Overview ¶
Package inventory is the deployment-tracking model. Keyed by SHA256 fingerprint, it turns rotation into a checklist and is persisted atomically.
Index ¶
- Constants
- func ComputeExpiry(created string, rotateAfterDays int) (string, error)
- func IsArchivedPathIn(path, root string) bool
- func RetiredPath(inventoryPath string) string
- func RevokedPath(inventoryPath string) string
- func Today() string
- type Deployment
- type Inventory
- type KeyRecord
- type Retirement
- type Retirements
- type Revocation
- type Revocations
Constants ¶
const ( StatusNotDeployed = "not-deployed" // no deployment recorded: a fresh or regenerated key StatusNeedsRedeploy = "needs-redeploy" // deployments recorded, none verified StatusDeployed = "deployed" // at least one verified deployment )
Deployment status values, as list, audit, export and the web show them.
Variables ¶
This section is empty.
Functions ¶
func ComputeExpiry ¶
ComputeExpiry returns created (YYYY-MM-DD) + rotateAfterDays as YYYY-MM-DD.
func IsArchivedPathIn ¶ added in v0.1.6
IsArchivedPathIn reports whether path is a rotation's /old/ predecessor slot under the key root, i.e. .../<root>/[<category>/]<profile>/old/<key_name> (by structure, so a profile literally named "old" is not mistaken for an archived key).
func RetiredPath ¶ added in v0.1.6
RetiredPath is retired.json, beside the inventory at inventoryPath. A file of its own for the reason revoked.json is one: the inventory decodes strictly, so a new field would make an older authama refuse it.
func RevokedPath ¶ added in v0.1.6
RevokedPath is revoked.json, beside the inventory at inventoryPath. A file of its own, not a field: the inventory decodes strictly, so a new field would make an older authama refuse the whole inventory.
Types ¶
type Deployment ¶
type Deployment struct {
Target string `json:"target"`
Method string `json:"method"` // ssh-copy-id | web-panel | manual | <adapter>
Date *string `json:"date"`
Verified bool `json:"verified"` // all false == needs-redeploy
}
Deployment records a key installed on one target.
func (*Deployment) UnmarshalJSON ¶
func (d *Deployment) UnmarshalJSON(b []byte) error
type Inventory ¶
Inventory is the whole inventory, keyed by fingerprint.
func (*Inventory) Save ¶
Save writes the inventory as indented JSON, atomically.
Via a temp file and a rename, not os.WriteFile: WriteFile truncates the target and then writes, so a crash or a full disk mid-write leaves a truncated inventory - the record of every key's expiry and deployments, lost to a partial write. It also keeps whatever mode the file already had, so an inventory that had somehow become group-readable stayed that way.
func (*Inventory) UnmarshalJSON ¶
type KeyRecord ¶
type KeyRecord struct {
Profile string `json:"profile"`
Path string `json:"path"`
Type string `json:"type"`
Comment *string `json:"comment"`
Created *string `json:"created"`
RotateAfterDays int `json:"rotate_after_days"`
ExpiresOn *string `json:"expires_on"`
Deployments []Deployment `json:"deployments"`
}
KeyRecord is one managed key and where it is deployed. All fields serialize unconditionally (null for an unset pointer, [] for no deployments) to match the serializer v1 and v2 used, byte-for-byte.
func (KeyRecord) DeployStatus ¶ added in v0.1.6
DeployStatus names the key's state: not-deployed when nothing is recorded, needs-redeploy when deployments are recorded but none is verified, deployed otherwise.
func (KeyRecord) MarshalJSON ¶
MarshalJSON emits a nil Deployments slice as [] (not null), matching the default_factory=list. The pointer fields already emit null when unset.
func (KeyRecord) NeedsRedeploy ¶
NeedsRedeploy is true when no deployment is verified (e.g. a fresh key). It is true for not-deployed keys too; DeployStatus tells the two apart.
func (*KeyRecord) UnmarshalJSON ¶
type Retirement ¶ added in v0.1.6
type Retirement struct {
Key string `json:"key"` // profile/key_name
Successor string `json:"successor"`
RetiredOn string `json:"retired_on"`
Removed []string `json:"removed_from"`
NotRemoved []string `json:"not_removed_from"`
ByHand map[string]string `json:"by_hand,omitempty"` // target -> where its keys are managed
}
Retirement is one key a rotation replaced: what it was, its successor, when it was retired, and the targets the rotation removed it from, could not remove it from, and that take it off by hand (with where). It is not a revocation: rollback may still bring a retired key back, while deploy and rollback refuse a revoked one.
type Retirements ¶ added in v0.1.6
type Retirements map[string]Retirement
Retirements is retired.json: retirements by the retired key's fingerprint.
func LoadRetirements ¶ added in v0.1.6
func LoadRetirements(path string) (Retirements, error)
LoadRetirements reads path; a missing file is no retirements.
func (Retirements) Save ¶ added in v0.1.6
func (r Retirements) Save(path string) error
Save writes the record owner-only, lists sorted.
type Revocation ¶ added in v0.1.6
type Revocation struct {
Key string `json:"key"` // profile/key_name
RevokedOn string `json:"revoked_on"`
Reason string `json:"reason,omitempty"`
Removed []string `json:"removed_from"`
NotRemoved []string `json:"not_removed_from"`
}
Revocation is one revoked key: the key it was, when it was revoked, and the targets it was removed from and could not be removed from. A fingerprint in the record is never deployed again; a regenerated or rotated key has a new fingerprint and is not affected.
type Revocations ¶ added in v0.1.6
type Revocations map[string]Revocation
Revocations is revoked.json: revocations by fingerprint.
func LoadRevocations ¶ added in v0.1.6
func LoadRevocations(path string) (Revocations, error)
LoadRevocations reads path; a missing file is no revocations.
func (Revocations) Save ¶ added in v0.1.6
func (r Revocations) Save(path string) error
Save writes the record owner-only, keys sorted (json sorts map keys).