Watch
0
0
Fork
You've already forked hyperhive
0
hyperhive/nix/host-modules/glue-secret-publisher-bao-identity.nix
atlas 2fc63d844b name the mint, not the publisher, as the writer of the client secrets
Finishes the sweep of prose that said the publisher unit writes or carries the OIDC client secrets: rust docs, nix comments and option descriptions, test names and docs.
2026-10-30 16:57:58 +01:00

48 lines
1.9 KiB
Nix

# Glue: point the secret publisher at the bao leaf minted for it.
#
# ONE PAIRING PER FILE — publisher ← bao, and nothing else. Deleting this
# leaves a publisher that takes operator-provided certificate paths, which is
# what any deployment not minting its own already does.
#
# ⚠️ The minting is NOT here. ./glue-bao-tls.nix holds the CA and signs the
# leaf, because the thing that owns a private key owns issuing from it. What
# belongs here is the pairing: which host paths go to the publisher's identity in
# authelia's container.
#
# ⚠️ Gated on a PKI directory existing, not on the store alone — the same rule
# ./glue-controller-bao-identity.nix states. A publisher on the store's own
# host is one deployment; a publisher beside a remote authelia holding a leaf
# issued out of band is another, and both want this wiring.
#
# Everything is `mkDefault`. An operator naming their own paths wins.
{
lib,
config,
...
}:
let
hyperhiveCfg = config.services.hyperhive;
deployCfg = hyperhiveCfg.deploy;
baoDeploy = deployCfg.bao;
# Where ./glue-bao-tls.nix puts the leaves. An operator's own `clientCertFile`
# names the directory when one is set (an operator who moves the PKI moves
# both, and the two cannot drift apart); on a store host that runs no hive
# there is no reader leaf to derive from, so it is the store's directory.
haveMintedPki = baoDeploy.clientCertFile != null || baoDeploy.enable;
pkiDir =
if baoDeploy.clientCertFile != null then
builtins.dirOf baoDeploy.clientCertFile
else if baoDeploy.enable then
import ./lib/bao-pki-dir.nix
else
null;
in
{
config = lib.mkIf (deployCfg.swarm-secret-publisher.enable && haveMintedPki) {
services.hyperhive.deploy.swarm-secret-publisher = {
baoClientCertFile = lib.mkDefault "${pkiDir}/secret-publisher.pem";
baoClientKeyFile = lib.mkDefault "${pkiDir}/secret-publisher-key.pem";
};
};
}