the queue's exporter asks every request for a login the gateway supplies
This commit is contained in:
parent
f54aae7927
commit
893b693b46
2 changed files with 488 additions and 133 deletions
|
|
@ -2245,8 +2245,8 @@ let
|
|||
}
|
||||
{
|
||||
# Create without update: the first value stored is the one every later
|
||||
# run reads, and no run replaces it. The two leaves are the stores'.
|
||||
name = "the store credential publisher's grant is create and read on the two stores' credentials and nothing else, and the PKI unit signs its leaf";
|
||||
# run reads, and no run replaces it. Two leaves are the stores', the third the exporter's.
|
||||
name = "the store credential publisher's grant is create and read on the two stores' and the queue exporter's credentials and nothing else, and the PKI unit signs its leaf";
|
||||
ok =
|
||||
let
|
||||
s = baoGrantHere.systemd.services.swarm-bao-store-auth-policy.script;
|
||||
|
|
@ -2262,7 +2262,12 @@ let
|
|||
"create"
|
||||
"read"
|
||||
]
|
||||
&& lib.length grants == 2
|
||||
&&
|
||||
(grantFor grants "secret/data/swarm/services/nats/exporter-auth").caps == [
|
||||
"create"
|
||||
"read"
|
||||
]
|
||||
&& lib.length grants == 3
|
||||
&& lib.hasInfix "auth/cert/certs/swarm-store-auth" s
|
||||
&& lib.hasInfix "allowed_common_names=swarm-store-auth" s
|
||||
&& lib.hasInfix "token_policies=swarm-store-auth" s
|
||||
|
|
|
|||
|
|
@ -2242,6 +2242,57 @@ let
|
|||
&& !(noNode.services.nginx.virtualHosts ? ${h.swarm.victorialogs.domain})
|
||||
&& !(noNode.services.nginx.virtualHosts ? ${h.swarm.victoriametrics.domain});
|
||||
}
|
||||
{
|
||||
# The exporter's login has the same three ends as the stores', with the
|
||||
# hash in place of the password in the pod. The literals are spelled here,
|
||||
# not read from the module.
|
||||
name = "the queue's exporter asks every request for a login whose bcrypt hash a Secret supplies, the gateway's location sends the password, and the unit creates, hashes and publishes it";
|
||||
ok =
|
||||
let
|
||||
h = allLocal.services.hyperhive;
|
||||
unit = allLocal.systemd.services.swarm-bao-store-auth;
|
||||
exporter = lib.findFirst (c: c.name == "exporter") null (podSpec "swarm-nats").containers;
|
||||
after =
|
||||
flag: lib.elemAt exporter.args ((lib.lists.findFirstIndex (a: a == flag) (-1) exporter.args) + 1);
|
||||
locations = allLocal.services.nginx.virtualHosts.${h.swarm.nats.domain}.locations;
|
||||
include = "include /var/lib/swarm-store-auth/nats.conf;";
|
||||
rule = "f /var/lib/swarm-store-auth/nats.conf 0600 root root -";
|
||||
in
|
||||
after "-http_user" == "swarm-exporter"
|
||||
# The argument is the variable Kubernetes substitutes, and the Secret it
|
||||
# names holds the hash only, never the password.
|
||||
&& after "-http_pass" == "$(EXPORTER_HASH)"
|
||||
&&
|
||||
exporter.env == [
|
||||
{
|
||||
name = "EXPORTER_HASH";
|
||||
valueFrom.secretKeyRef = {
|
||||
name = "swarm-nats-exporter-auth";
|
||||
key = "hash";
|
||||
};
|
||||
}
|
||||
]
|
||||
# The gateway's `/metrics` location sends the password; the
|
||||
# authorization subrequest and the catch-all do not. The location is
|
||||
# the control that the lookup finds one.
|
||||
&& hasInfix include locations."= /metrics".extraConfig
|
||||
&& lib.all (n: !(hasInfix "/var/lib/swarm-store-auth" (locations.${n}.extraConfig or ""))) (
|
||||
lib.filter (n: n != "= /metrics") (lib.attrNames locations)
|
||||
)
|
||||
&& lib.length (lib.attrNames locations) >= 3
|
||||
# The unit mints the password, hashes it as `$2a$` at NATS's own cost
|
||||
# from stdin, and gives the cluster the hash alone.
|
||||
&& hasInfix "secret/swarm/services/nats/exporter-auth" unit.script
|
||||
&& hasInfix "/var/lib/swarm-store-auth/nats.conf" unit.script
|
||||
&& hasInfix "htpasswd -niBC 11 x" unit.script
|
||||
&& hasInfix "[$]2y[$]/$2a$/" unit.script
|
||||
&& hasInfix "--from-literal=hash=" unit.script
|
||||
&& hasInfix "swarm-nats-exporter-auth" unit.script
|
||||
&& !(hasInfix "--from-file=hash" unit.script)
|
||||
&& lib.elem rule allLocal.systemd.tmpfiles.rules
|
||||
# Without the queue there is no file for it.
|
||||
&& !(lib.elem rule noNode.systemd.tmpfiles.rules);
|
||||
}
|
||||
{
|
||||
# The two `auth_request` responders hold no state and log in under one
|
||||
# role, so they are one pod with one account that may run on any node.
|
||||
|
|
|
|||
Loading…
Reference in a new issue