bao: the queue pod's two jwt roles share one ServiceAccount
This commit is contained in:
parent
bcbba8d605
commit
614543f716
3 changed files with 27 additions and 9 deletions
|
|
@ -470,6 +470,9 @@ let
|
|||
# by spelling it the same way, and is itself named after it.
|
||||
controllerPolicyName = "swarm-controller";
|
||||
|
||||
# The queue's principal: its policy and its cert-auth role carry this name.
|
||||
natsPolicyName = "swarm-nats";
|
||||
|
||||
in
|
||||
{
|
||||
inherit
|
||||
|
|
@ -525,6 +528,7 @@ in
|
|||
listStanza
|
||||
openbaoStartSec
|
||||
openbaoStopSec
|
||||
natsPolicyName
|
||||
readStanza
|
||||
refreshConsumer
|
||||
servicesPkiRootLabel
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ let
|
|||
controllerForgeTokenLeaf
|
||||
controllerGrafanaTokenLeaf
|
||||
controllerPolicyName
|
||||
natsPolicyName
|
||||
createStanza
|
||||
credentialMountPath
|
||||
grafanaAdminLeaf
|
||||
|
|
@ -417,16 +418,27 @@ let
|
|||
++ reviewClassifierReaders
|
||||
++ claudeLoginWriters
|
||||
++ ciMetricsReaders
|
||||
++ [ { name = controllerPolicyName; } ];
|
||||
++ [ { name = controllerPolicyName; } ]
|
||||
# The queue's pod holds both of its roles under one ServiceAccount: the
|
||||
# server's leaf is issued with `swarm-nats`, and the responder reads its
|
||||
# keys and credentials with `swarm-nats-auth`.
|
||||
++ map (obj: obj // { serviceAccount = natsPodAccount; }) (
|
||||
[ { name = natsPolicyName; } ] ++ natsAuthReaders
|
||||
);
|
||||
|
||||
# The jwt role of one principal: the token of exactly its ServiceAccount, for
|
||||
# this store's audience. Both the subject and the audience are bound, so a
|
||||
# The ServiceAccount the queue's pod runs under, as ../k8s/render.nix names
|
||||
# it: the pod is the service `swarm-nats`.
|
||||
natsPodAccount = "swarm-nats";
|
||||
|
||||
# The jwt role of one principal: the token of exactly its ServiceAccount (the
|
||||
# one of its name, unless the record names another), for this store's
|
||||
# audience. Both the subject and the audience are bound, so a
|
||||
# token of another account, or one minted for the Kubernetes API, is refused.
|
||||
k8sJwtRoleWrite = obj: ''
|
||||
bao write auth/${podAuth.mount}/role/${lib.escapeShellArg obj.name} \
|
||||
role_type=jwt \
|
||||
user_claim=sub \
|
||||
bound_subject=${lib.escapeShellArg "system:serviceaccount:${hyperhiveCfg.k8s.namespace}:${obj.name}"} \
|
||||
bound_subject=${lib.escapeShellArg "system:serviceaccount:${hyperhiveCfg.k8s.namespace}:${obj.serviceAccount or obj.name}"} \
|
||||
bound_audiences=${lib.escapeShellArg podAuth.audience} \
|
||||
token_policies=${lib.escapeShellArg obj.name}${roleTokenArgs obj}
|
||||
'';
|
||||
|
|
@ -450,10 +462,12 @@ in
|
|||
internal = true;
|
||||
default = map (p: p.name) k8sPrincipals;
|
||||
description = ''
|
||||
The in-cluster services that log in to the store with a ServiceAccount
|
||||
token. Each is one principal: its cert-auth role and its jwt role carry
|
||||
the same name, policy and token lifetimes, and its pod runs under a
|
||||
ServiceAccount of that name.
|
||||
The principals of the in-cluster services that log in to the store with
|
||||
a ServiceAccount token. Each is one principal: its cert-auth role and
|
||||
its jwt role carry the same name, policy and token lifetimes, and its
|
||||
pod runs under a ServiceAccount of that name. The queue's pod is the
|
||||
exception: it holds two principals, `swarm-nats` and
|
||||
`swarm-nats-auth`, under the one ServiceAccount `swarm-nats`.
|
||||
'';
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -74,6 +74,7 @@ let
|
|||
controllerGrafanaTokenLeaf
|
||||
controllerPolicyName
|
||||
controllerWebhookSecretLeaf
|
||||
natsPolicyName
|
||||
createStanza
|
||||
credentialMountPath
|
||||
grafanaAdminLeaf
|
||||
|
|
@ -899,7 +900,6 @@ let
|
|||
|
||||
# The queue's principal: one `update` on its own role, the shape of the
|
||||
# services issuer's grant above, narrowed to one name by the role itself.
|
||||
natsPolicyName = "swarm-nats";
|
||||
natsCn = baoDeploy.natsCommonName;
|
||||
natsPkiRoleName = baoDeploy.natsPkiRoleName;
|
||||
natsPolicyText = ''
|
||||
|
|
|
|||
Loading…
Reference in a new issue