Skip to main content

Module rotation

Module rotation 

Source
Expand description

The rotation state machine (R13): rotate a credential at its issuer, deploy it to the things that use it, check them, and revoke the old credential only when that is safe.

The engine owns the order of steps and the safety rules; it knows nothing about any one issuer or deployment. Those arrive as traits (IssuerConnector, Consumers, EntryStore), so the same state machine runs against PostgreSQL, Cloudflare or a fake that injects faults, and the properties below are tested against the fake.

The rules, in the order they matter:

  1. The old credential stays valid until the end. It is revoked last, and only when the revoke rule is met: by default every required consumer has been deployed to and has passed its check in this run (RevokeRule::AfterAllChecked).
  2. A value the client chose is stored before the issuer hears of it (rotation_pending), so a lost response never leaves a credential at the issuer that nobody has.
  3. No blind retry of anything destructive. A response lost after a destructive call is uncertain; the connector is asked what happened (IssuerConnector::reconcile) and the step is repeated only when the answer is “not done”. An in-place roll that is lost cannot be reconciled (the old value is gone and the new one never arrived) and stops as needs_attention.
  4. Store first. The new value is written to the entry (a new generation, the old value in its history) before it is deployed, so a crash after the issuer changed cannot lose it.
  5. Every transition is persisted (RunStore), so a crash, a lock or a restart resumes at the step that was in flight and never starts over.

Structs§

Credential
Engine
Policy
Run
SqlStore

Enums§

Class
What a connector can do. The class decides the steps.
IssuerError
Why an issuer call did not succeed.
Outcome
Reconcile
RevokeRule
RollbackRule
Status
Step
StepKind
The step a reconcile is about.

Traits§

Consumers
What uses the credential, usually node targets. Each consumer is identified by a stable id.
EntryStore
The vault entry being rotated.
IssuerConnector
RunStore
Where runs and pending values are kept between steps.

Functions§

init_schema
Creates the rotation tables inside the encrypted vault database. Runs hold ids and states, never values; rotation_pending holds the one value that exists nowhere else yet.
list_runs
load_run
A run saved by SqlStore, to resume after a crash or an unlock.
run_name