swarm-bao: move the per-principal reader policy units out
The 17 swarm-bao-*-policy units that write a service's own policy and cert-auth role (Grafana, the collector, the queue and store responders, the CI runner and poller, the classifier, the builder, the cache, the archive, the claude login minter, the notification router, stt and the forge publisher) are their own module, with the reader lists and the unit shape they use. The stanzas, leaves and unit helpers the host module also reads join lib/swarm-bao-shared.nix. Refs #6820
This commit is contained in:
parent
5dacfdb320
commit
a5a0b4a489
1 changed files with 602 additions and 507 deletions
|
|
@ -265,6 +265,119 @@ let
|
|||
gatewayCfg = hyperhiveCfg.gateway;
|
||||
};
|
||||
|
||||
# The swarm appservice token's leaf, the nix half of
|
||||
# `swarm_secret_client::matrix::swarm_appservice_token_path`. Under
|
||||
# `controller/`, the one kind no hive's policy reads: its sender is the
|
||||
# homeserver's admin.
|
||||
swarmAppserviceTokenLeaf = "swarm/controller/swarm-controller/matrix/appservice-token";
|
||||
|
||||
# The swarm appservice registration's leaf, the nix half of
|
||||
# `swarm_secret_client::matrix::swarm_appservice_registration_path`. Only
|
||||
# matrix-ctl reaches it; the controller reads the token above, not this.
|
||||
swarmAppserviceRegistrationLeaf = "swarm/controller/swarm-controller/matrix/appservice-registration";
|
||||
|
||||
# The controller's own OIDC client secret, the nix half of
|
||||
# `swarm_secret_client::queue::controller_client_path`. Authelia's mint writes
|
||||
# it; the controller reads it and holds no other copy.
|
||||
controllerClientLeaf = "swarm/controller/swarm-controller/oidc/client";
|
||||
|
||||
# The controller's own forge token, the nix half of
|
||||
# `swarm_secret_client::forge::controller_token_path`. The forge's host writes
|
||||
# it; the controller reads it and holds no other copy.
|
||||
controllerForgeTokenLeaf = "swarm/controller/swarm-controller/forge/token";
|
||||
|
||||
# The controller's Viewer token for Grafana's API, the nix half of
|
||||
# `swarm_secret_client::grafana::controller_token_path`. Grafana's host
|
||||
# writes it; the controller reads it and holds no other copy.
|
||||
controllerGrafanaTokenLeaf = "swarm/controller/swarm-controller/grafana/token";
|
||||
|
||||
# The HMAC secret of the swarm-wide forge webhooks, the nix half of
|
||||
# `swarm_secret_client::forge::controller_webhook_secret_path`. The controller
|
||||
# creates it, seeded from its old state-directory file, and reads it; `create`
|
||||
# without `update`, so the first value stored is the one every start reads.
|
||||
controllerWebhookSecretLeaf = "swarm/controller/swarm-controller/forge/webhook-secret";
|
||||
|
||||
# The forge's runner registration token, the nix half of
|
||||
# `swarm_secret_client::ci::registration_token_path`. The controller writes
|
||||
# it and cannot read it back (`forge::runner_token` keeps the value it last
|
||||
# wrote in memory); the CI runner's fetch unit is its one reader.
|
||||
ciRunnerTokenLeaf = "swarm/services/ci-runner/registration-token";
|
||||
|
||||
# The review classifier's forge token, the nix half of
|
||||
# `swarm_secret_client::review_classifier::forge_token_path`. The controller
|
||||
# mints it, reads it back before deciding whether to re-mint, and posts the
|
||||
# classifier's reviews with it; no other principal's policy reaches it.
|
||||
classifierForgeTokenLeaf = "swarm/services/review-classifier/forge/token";
|
||||
|
||||
# The swarm builder's forge token, the nix half of
|
||||
# `swarm_secret_client::builder::forge_token_path`. The controller mints it
|
||||
# and reads it back before deciding whether to re-mint; the builder reads it
|
||||
# to fetch config repos.
|
||||
builderForgeTokenLeaf = "swarm/services/builder/forge/token";
|
||||
|
||||
# The CI run poller's forge token, the nix half of
|
||||
# `swarm_secret_client::ci_metrics::forge_token_path`. The controller mints it
|
||||
# and reads it back before deciding whether to re-mint; the poller reads it
|
||||
# to list runs.
|
||||
ciMetricsForgeTokenLeaf = "swarm/services/ci-metrics/forge/token";
|
||||
|
||||
readStanza = path: ''
|
||||
path "${path}" {
|
||||
capabilities = ["read"]
|
||||
}
|
||||
'';
|
||||
|
||||
listStanza = path: ''
|
||||
path "${path}" {
|
||||
capabilities = ["list"]
|
||||
}
|
||||
'';
|
||||
|
||||
# The callout's keys, the nix half of `swarm-nats-auth`'s `xkey::SEED_PATH`
|
||||
# and `xkey::PUBLIC_PATH`, and of the `seed_path` and `public_path` of
|
||||
# `nkey::ISSUER` and `nkey::USER`. All are readable by the `swarm-nats-auth`
|
||||
# role alone: `swarm/public/` marks the halves that are no secret, and no
|
||||
# policy opens them to every token.
|
||||
xkeySeedLeaf = "swarm/services/swarm-nats/callout/xkey-seed";
|
||||
xkeyPublicLeaf = "swarm/public/swarm-nats/callout-xkey";
|
||||
issuerSeedLeaf = "swarm/services/swarm-nats/callout/issuer-seed";
|
||||
issuerPublicLeaf = "swarm/public/swarm-nats/callout-issuer";
|
||||
userSeedLeaf = "swarm/services/swarm-nats/callout/user-seed";
|
||||
userPublicLeaf = "swarm/public/swarm-nats/callout-user";
|
||||
|
||||
# Grafana's admin password, which only Grafana's leaf creates. The nix half
|
||||
# of `adminPasswordStorePath` in ./swarm-grafana.nix.
|
||||
grafanaAdminLeaf = "swarm/services/${hyperhiveCfg.swarm.grafana.oidc.clientId}/admin/password";
|
||||
|
||||
# The bearer Grafana's datasources present at the metrics and log stores.
|
||||
# Grafana's leaf creates it, the stores' responders read it. The nix half of
|
||||
# `metricsBearerStorePath` in ./swarm-grafana.nix and of `--store-path` in
|
||||
# ./swarm-victoriametrics.nix and ./swarm-victorialogs.nix.
|
||||
grafanaMetricsBearerLeaf = "swarm/services/${hyperhiveCfg.swarm.grafana.oidc.clientId}/metrics/bearer";
|
||||
|
||||
# Grafana's datasource-encryption key, which only Grafana's leaf creates. The
|
||||
# nix half of `secretKeyStorePath` in ./swarm-grafana.nix.
|
||||
grafanaSecretKeyLeaf = "swarm/services/${hyperhiveCfg.swarm.grafana.oidc.clientId}/secret-key";
|
||||
|
||||
# authelia's jwt, session, storage-encryption, OIDC HMAC and OIDC issuer keys,
|
||||
# which only `authelia-swarm-secrets` in authelia's container creates and reads.
|
||||
# The nix half of `keyLeaf` in ./swarm-authelia.nix. `create` without
|
||||
# `update`, so a stored key is never replaced: the storage-encryption key
|
||||
# encrypts authelia's database and the issuer key signs every id token.
|
||||
autheliaKeyLeaves = map (name: "swarm/services/${autheliaCfg.machine}/keys/${name}") [
|
||||
"jwt"
|
||||
"session"
|
||||
"storage-encryption"
|
||||
"oidc-hmac"
|
||||
"oidc-issuer"
|
||||
];
|
||||
|
||||
createStanza = path: ''
|
||||
path "${path}" {
|
||||
capabilities = ["create", "read"]
|
||||
}
|
||||
'';
|
||||
|
||||
in
|
||||
{
|
||||
inherit
|
||||
|
|
@ -276,14 +389,27 @@ in
|
|||
atticPushTokenLeaf
|
||||
atticUrlLeaf
|
||||
autheliaCfg
|
||||
autheliaKeyLeaves
|
||||
baoCli
|
||||
baoStoreUp
|
||||
baoUiClientLeaf
|
||||
builderForgeTokenLeaf
|
||||
caTrust
|
||||
certRoleTokenTtl
|
||||
ciMetricsForgeTokenLeaf
|
||||
ciRunnerTokenLeaf
|
||||
classifierAcpKeyLeaf
|
||||
classifierApiKeyLeaf
|
||||
classifierForgeTokenLeaf
|
||||
controllerClientLeaf
|
||||
controllerForgeTokenLeaf
|
||||
controllerGrafanaTokenLeaf
|
||||
controllerWebhookSecretLeaf
|
||||
createStanza
|
||||
credentialMountPath
|
||||
grafanaAdminLeaf
|
||||
grafanaMetricsBearerLeaf
|
||||
grafanaSecretKeyLeaf
|
||||
granterAfter
|
||||
granterCn
|
||||
granterEnv
|
||||
|
|
@ -294,6 +420,16 @@ in
|
|||
haveBootstrapToken
|
||||
haveGranter
|
||||
haveServerTls
|
||||
issuerPublicLeaf
|
||||
issuerSeedLeaf
|
||||
listStanza
|
||||
readStanza
|
||||
swarmAppserviceRegistrationLeaf
|
||||
swarmAppserviceTokenLeaf
|
||||
tlsDir
|
||||
userPublicLeaf
|
||||
userSeedLeaf
|
||||
xkeyPublicLeaf
|
||||
xkeySeedLeaf
|
||||
;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue