Watch
0
0
Fork
You've already forked hyperhive
0

gateway reaches the controller over tls with its own client leaf when the tcp listener is on

This commit is contained in:
atlas 2026-11-15 16:10:59 +01:00 • committed by mara
commit 187ed82de0

View file

@ -650,6 +650,13 @@ let
path "${sshAgentsMountPath}/config/ca" {
capabilities = ["read"]
}
''
# The controller's TCP listener leaf: one issue path on a role of its own,
# present only where the listener is on.
+ lib.optionalString tcpCfg.enable ''
path "${servicesPkiMountPath}/issue/${tcpCfg.serverPkiRole}" {
capabilities = ["update"]
}
'';
# The identity authelia's mint creates its OIDC client secrets in the store
@ -979,6 +986,10 @@ let
# and has to spell it the same way.
servicesPkiMountPath = baoDeploy.servicesPkiMountPath;
# The controller's optional TCP listener: its two roles are written here, and
# its two principals are granted the matching issue paths below.
tcpCfg = hyperhiveCfg.swarm.controller.tcp;
# Subject of the root generated into that mount. A label for a human reading
# a chain, not an identity anything authenticates against. Falls through so
# a hive that has set neither a swarm name nor a domain still evaluates.
@ -1015,6 +1026,38 @@ let
servicesPkiLeafTtl = "${toString servicesPkiLeafTtlHours}h";
servicesPkiLeafTtlSeconds = servicesPkiLeafTtlHours * 3600;
# The two roles, as script to splice after the services role's write.
# Empty where the listener is off, so the unit's script is the one it was
# before. Same narrowing as the services role, one name each:
# * `serverPkiRole` issues the listener's server leaf for `tcp.domain`
# alone, `serverAuth` only.
# * `clientPkiRole` issues the gateway's client leaf for `tcp.clientName`
# alone, `clientAuth` only. The opposite flag pair from the services
# role, which is why the services leaf cannot present itself to the
# listener.
tcpRoleWrite = role: name: flags: ''
bao write ${lib.escapeShellArg "${servicesPkiMountPath}/roles/${role}"} \
allowed_domains=${lib.escapeShellArg (toString name)} \
allow_bare_domains=true \
allow_subdomains=false \
allow_glob_domains=false \
allow_localhost=false \
allow_any_name=false \
allow_ip_sans=false \
enforce_hostnames=true \
${flags} \
key_type=rsa \
key_bits=4096 \
ttl=${servicesPkiLeafTtl} \
max_ttl=${servicesPkiLeafTtl}
'';
tcpRoles = lib.optionalString tcpCfg.enable (
"\n\n"
+ tcpRoleWrite tcpCfg.serverPkiRole tcpCfg.domain "server_flag=true client_flag=false"
+ "\n"
+ tcpRoleWrite tcpCfg.clientPkiRole tcpCfg.clientName "server_flag=false client_flag=true"
);
# The role every swarm-service certificate will be issued through, and the
# whole narrowing of this mount. A role rather than a name-constrained
# sub-CA: the engine enforces "these names and no others" at issue time, so
@ -1049,6 +1092,15 @@ let
path "${servicesPkiMountPath}/issue/${servicesPkiRoleName}" {
capabilities = ["update"]
}
''
# The gateway's client leaf for the controller's TCP listener. Every gateway
# host holds this identity, so every gateway host can obtain the leaf: what the
# controller trusts is "a gateway of this swarm". The role issues one name,
# with `clientAuth` only.
+ lib.optionalString tcpCfg.enable ''
path "${servicesPkiMountPath}/issue/${tcpCfg.clientPkiRole}" {
capabilities = ["update"]
}
'';
# The queue's principal: one `update` on its own role, the shape of the
@ -4057,7 +4109,7 @@ in
key_type=rsa \
key_bits=4096 \
ttl=${servicesPkiLeafTtl} \
max_ttl=${servicesPkiLeafTtl}
max_ttl=${servicesPkiLeafTtl}${tcpRoles}
# `certificate=` is the CA, so this role trusts every leaf that
# CA signed and `allowed_common_names` is the whole narrowing —