Let one provider carry a per-target credential #16
Labels
No labels
bug
duplicate
enhancement
help wanted
invalid
question
wontfix
bug
duplicate
enhancement
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
allod/secrets#16
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Let a provider authenticate with a different bearer on each machine that uses it, so a deployment can give every target its own credential for one shared endpoint instead of copying one bearer to all of them.
Primary goals:
Current state
A provider ID may belong to exactly one credential.
lib/pi-credential-schema.nix:79collects every provider across the registry and:95throwsproviders referenced by multiple credentialson any repeat, so two credentials cannot both serve one provider. A credential'stargetslist then fans that single bearer out to every machine named, andlib/pi-credential-recipients.nix:60-61encrypts one ciphertext per token to the union of those targets' host keys. The result is deliberate and correct for a shared service account; it has no expression for a per-machine one.The global provider-to-credential map at
lib/pi-credential-contract.nix:169-173is where the single-credential assumption is baked in: it is a flatprovider -> credentialattrset with no target dimension.The per-machine projection is already closer to the target shape than that map is.
projectionForat:192-216selects the credentials naming a target and derives that machine's providers from them, so a projection is keyed by target already and each machine only ever learns about its own credential. A per-target credential mostly changes what the projection selects, not its shape.Suggested direction
Give
targetsa per-target credential rather than making a provider name repeatable. The registry entry shape atlib/pi-credential-schema.nix:5is the natural place to decide this, and the decision governs the size of the change: extending an existing field keeps the migration mechanical, while a new field means every consumer's exact-field check has to move together.Whatever shape wins, three things follow: the uniqueness rule at
:95narrows from "a provider appears once" to "a provider appears once per target"; the recipient derivation encrypts each machine's ciphertext to that machine alone rather than to the union; and the globalproviderCredentialsexport either gains a target dimension or stops being derivable and its consumers move to the projection.The recipient change is the one with a real failure mode. Today every target of a credential can decrypt the same file, and a bug that widens a recipient set is invisible at evaluation time. Whatever lands should have a check that a per-target ciphertext lists exactly one machine's host keys beside the hypervisor's.
Scope
In scope: the registry shape, the uniqueness rule, the projection, the recipient derivation, and the fixtures and checks covering them.
Out of scope, tracked separately: the operator tool that writes registries and ciphertext needs a way to add a target with its own bearer, tracked as
allod/nexusissue #36, which cannot be designed before this contract settles. Consumers that vendorlib/pi-credential-schema.nixorlib/pi-credential-recipients.nixto reach them without a flake input must re-vendor after this lands; that is deployment work, not framework work, but the change should not silently assume a single copy exists.Migrating an existing shared credential to per-target ones is a deployment action requiring the bearers in hand, so this issue owes a documented migration path, not a migration.