swarm: OIDC clients registered wherever authelia runs; nats + matrix secrets from bao
The three client registrations move into glue-{controller,nats,matrix}-oidc-client.nix,
gated only on deploy.authelia.enable and reading their ids from swarm.* options,
so the host running authelia registers every one of them whichever host runs
the service. The matrix callback is a new read-only swarm.matrix.sso.redirectUri,
read by both the homeserver's config and its client entry.
swarm-secret-publish now also publishes the queue's and the homeserver's minted
secrets to swarm/services/<id>/oidc/client. The queue host reads its responder's
secret there with swarm-bao-nats-auth-oidc under the responder's own leaf
(swarm-nats-auth role gains that one read path), and the homeserver's host with
swarm-bao-matrix-oidc under matrix-ctl's leaf (swarm-matrix-ctl role gains its
one read path). The host-file copies are gone: swarm-nats-auth-secrets now
delivers only the callout seeds and the store identity, and
hive-matrix-oidc-secret is removed. A fetch unit whose leaf is unset still
renders and fails naming the option pair.
Closes #4943
This commit is contained in:
parent
72d0d8ccba
commit
962da3b784
20 changed files with 702 additions and 293 deletions
|
|
@ -71,6 +71,42 @@ let
|
|||
&& !(s.hive-c0re.environment ? BAO_ADDR)
|
||||
&& !(lib.any (c: lib.hasPrefix "bao-" c) s.hive-c0re.serviceConfig.LoadCredential);
|
||||
}
|
||||
{
|
||||
# The homeserver's OIDC secret has one route, the store, under
|
||||
# matrix-ctl's leaf, landing where `clientSecretFile` points inside the
|
||||
# container. No unit copies it out of authelia's tree, even on a host
|
||||
# that runs authelia.
|
||||
name = "the homeserver reads its OIDC secret from the store under matrix-ctl's leaf";
|
||||
ok =
|
||||
let
|
||||
s = matrixBodyCap.systemd.services;
|
||||
u = s.swarm-bao-matrix-oidc;
|
||||
m = matrixBodyCap.services.hyperhive.deploy.matrix;
|
||||
in
|
||||
matrixBodyCap.services.hyperhive.deploy.authelia.enable
|
||||
&& u.environment.BAO_CLIENT_CERT == m.ctlBaoClientCertFile
|
||||
&& u.environment.BAO_CLIENT_KEY == m.ctlBaoClientKeyFile
|
||||
&& m.sso.clientSecretFile == "/var/lib/tuwunel-oidc/tuwunel.secret"
|
||||
&& lib.hasInfix "bao kv get -field=value secret/swarm/services/tuwunel/oidc/client" u.script
|
||||
&& lib.hasInfix "/var/lib/nixos-containers/hive-matrix/var/lib/tuwunel-oidc/tuwunel.secret" u.script
|
||||
&& lib.hasInfix "refresh_consumer hive-matrix tuwunel.service" u.script
|
||||
&& lib.elem "container@hive-matrix.service" u.before
|
||||
&& !(s ? hive-matrix-oidc-secret);
|
||||
}
|
||||
{
|
||||
# No matrix-ctl leaf is a homeserver with no OIDC secret, which tuwunel
|
||||
# refuses to start on. The unit still renders, and fails naming the
|
||||
# options.
|
||||
name = "a homeserver host with no matrix-ctl leaf renders a secret fetch that fails naming the options";
|
||||
ok =
|
||||
let
|
||||
u = matrixNoBaoIdentity.systemd.services.swarm-bao-matrix-oidc;
|
||||
in
|
||||
!(u.environment ? BAO_CLIENT_CERT)
|
||||
&& lib.hasInfix "deploy.matrix.ctlBaoClientCertFile" u.script
|
||||
&& lib.hasInfix "exit 1" u.script
|
||||
&& !(lib.hasInfix "bao login" u.script);
|
||||
}
|
||||
{
|
||||
# hive-c0re logs in with the hive's matrix token over this URL, and on a
|
||||
# host without the homeserver that login crosses the network, so the
|
||||
|
|
|
|||
Loading…
Reference in a new issue