From c74e7fcc3004410d3237eeefd9f58b87c63179d8 Mon Sep 17 00:00:00 2001 From: Nikolai Emil Damm Date: Sun, 15 Nov 2026 11:37:40 +0100 Subject: [PATCH] feat(business-site): let the tenant read its billing keys and resolve their APIs Extend app-business-site-disclosure-readonly with read on exactly secret/data/apps/business-site/numina and secret/data/apps/business-site/stripe. It gets no wildcard, metadata, list or write capability. The payload checker, its rendered-payload contract (now 29 invalid-payload controls) and the docs that describe the role match. Add a platform-owned business-site-dns-visibility CiliumNetworkPolicy. It gives the business-site pods L7 DNS visibility to kube-dns, so the tenant's toFQDNs rules for api.numina.app and api.stripe.com can match. The generated allow-dns policy is L4-only, and the tenant cannot name kube-system itself. The policy opens no new peer or port. Both portal billing flags stay off, and no value is created. Refs #6337 Co-Authored-By: Claude Opus 5.5 --- docs/adr/email-outbound-relay.md | 3 +- docs/tenant-abstraction.md | 15 +++++---- .../infrastructure/vault-config/job.yaml | 18 ++++++++--- .../cilium-network-policy-dns-visibility.yaml | 31 +++++++++++++++++++ .../apps/business-site/kustomization.yaml | 1 + .../check-business-disclosure-reader/main.go | 2 ++ .../tests/test-business-disclosure-reader.sh | 9 ++++-- 7 files changed, 65 insertions(+), 14 deletions(-) create mode 100644 k8s/providers/hetzner/apps/business-site/cilium-network-policy-dns-visibility.yaml diff --git a/docs/adr/email-outbound-relay.md b/docs/adr/email-outbound-relay.md index 41683adb47..b8fb154567 100644 --- a/docs/adr/email-outbound-relay.md +++ b/docs/adr/email-outbound-relay.md @@ -92,7 +92,8 @@ sign-in, recovery or public submission work, and it cannot reach any mailbox. - **Custody.** A platform PushSecret copies the key ID and the derived SMTP password to `apps/business-site/smtp` in OpenBao, as `username` and `password`. The business site reads that one key through its dedicated role, - which also reads its public disclosure and nothing else. + which otherwise reads only its public disclosure and its portal billing + keys (platform#6337). - **Use.** The site's mail client connects to `email-smtp.eu-central-1.amazonaws.com` on port 587 with STARTTLS and SMTP authentication, sending from `no-reply@devantler.tech`. The tenant owns its diff --git a/docs/tenant-abstraction.md b/docs/tenant-abstraction.md index 5e5807b819..03fc7ab16d 100644 --- a/docs/tenant-abstraction.md +++ b/docs/tenant-abstraction.md @@ -217,8 +217,10 @@ application. The maintained `vault-config` Job declares the `business-site` Kubernetes auth role for the same-named service account in only that namespace. Its sole token -policy reads the exact KV-v2 disclosure entry used by the source-owned -SecretStore; it grants no value writes, metadata listing or other application +policy reads four exact KV-v2 entries through the source-owned SecretStore: the +public disclosure, the platform-written SES SMTP credential, and the portal's +Numina (`apps/business-site/numina`) and Stripe (`apps/business-site/stripe`) +billing keys. It grants no value writes, metadata listing or other application paths. The only other permissions are lookup and revocation of the token itself, which the pinned ESO client uses when reusing and closing its authenticated connection. These do not authorize lookup or revocation of another token. The @@ -228,15 +230,16 @@ it does not guess a separate audience absent from that store. The pinned ESO 2.13.0 Kubernetes connector passes the store's service-account audiences through to TokenRequest, without the `vault` default of its separate JWT connector. -The tenant owner materializes and maintains the confirmed disclosure privately -through the supported operator entry path. This role creates no value, enables -no WebApp and grants no customer identity or payment access. Missing/unsafe +The tenant owner materializes and maintains the confirmed disclosure and the +billing keys privately through the supported operator entry path. This role +creates no value, enables no WebApp and grants no customer identity access. +Reading the billing keys does not switch on either portal billing flag. Missing/unsafe projection refusal, actual ESO authentication and rotation, HTTPS staging and private-route closure remain live acceptance under #5247. Normal production reconciliation owns installation; a suspended deployment is not manually bypassed. `bash scripts/tests/test-business-disclosure-reader.sh` checks the actual rendered -role/policy payload and twenty-two invalid-payload controls without authenticating or +role/policy payload and twenty-nine invalid-payload controls without authenticating or reading any value. OpenBao supports the policy's native [JSON syntax](https://openbao.org/docs/concepts/policies/); the [Kubernetes role API](https://openbao.org/docs/api/auth/kubernetes/) defines the diff --git a/k8s/bases/infrastructure/vault-config/job.yaml b/k8s/bases/infrastructure/vault-config/job.yaml index bf2babc625..98bc29b191 100644 --- a/k8s/bases/infrastructure/vault-config/job.yaml +++ b/k8s/bases/infrastructure/vault-config/job.yaml @@ -836,10 +836,12 @@ spec: } POLICY - # The business site reads two exact entries: its owner-maintained - # public disclosure, and its send-only SES SMTP credential, which a - # platform PushSecret writes (platform#5400). It has no value - # writer, metadata listing or shared infrastructure policy. + # The business site reads four exact entries: its owner-maintained + # public disclosure, its send-only SES SMTP credential, which a + # platform PushSecret writes (platform#5400), and the portal's + # owner-maintained Numina and Stripe billing keys (platform#6337). + # It has no value writer, metadata listing or shared + # infrastructure policy. bao policy write app-business-site-disclosure-readonly - <<'BUSINESS_SITE_POLICY' { "path": { @@ -849,6 +851,12 @@ spec: "secret/data/apps/business-site/smtp": { "capabilities": ["read"] }, + "secret/data/apps/business-site/numina": { + "capabilities": ["read"] + }, + "secret/data/apps/business-site/stripe": { + "capabilities": ["read"] + }, "auth/token/lookup-self": { "capabilities": ["read"] }, @@ -1269,7 +1277,7 @@ spec: # The source-owned SecretStore uses only this namespaced identity. # Explicit JSON preserves array/boolean types; no default policy is - # added to the one-entry reader. The tenant owner supplies values. + # added to the exact-entry reader. The tenant owner supplies values. bao write auth/kubernetes/role/business-site - <<'BUSINESS_SITE_ROLE' { "bound_service_account_names": ["business-site"], diff --git a/k8s/providers/hetzner/apps/business-site/cilium-network-policy-dns-visibility.yaml b/k8s/providers/hetzner/apps/business-site/cilium-network-policy-dns-visibility.yaml new file mode 100644 index 0000000000..34a3059144 --- /dev/null +++ b/k8s/providers/hetzner/apps/business-site/cilium-network-policy-dns-visibility.yaml @@ -0,0 +1,31 @@ +# Cilium enforces a toFQDNs rule only for names its DNS proxy has seen, and the +# proxy sees a lookup only when an L7 `rules.dns` rule covers that traffic. The +# generated `allow-dns` policy is L4-only, and restrict-tenant-network-policies +# refuses a tenant selector naming kube-system, so the tenant cannot add this +# rule itself. It opens nothing new: `allow-dns` already allows the same port +# to the same peer, and matchPattern "*" leaves resolution unrestricted. The +# tenant's own toFQDNs rules (api.numina.app, api.stripe.com) still decide +# where traffic may go (platform#6337). +apiVersion: cilium.io/v2 +kind: CiliumNetworkPolicy +metadata: + name: business-site-dns-visibility + namespace: business-site +spec: + endpointSelector: + matchLabels: + app.kubernetes.io/name: business-site + egress: + - toEndpoints: + - matchLabels: + k8s:io.kubernetes.pod.namespace: kube-system + k8s-app: kube-dns + toPorts: + - ports: + - port: "53" + protocol: UDP + - port: "53" + protocol: TCP + rules: + dns: + - matchPattern: "*" diff --git a/k8s/providers/hetzner/apps/business-site/kustomization.yaml b/k8s/providers/hetzner/apps/business-site/kustomization.yaml index 6921c490df..cbba52fd77 100644 --- a/k8s/providers/hetzner/apps/business-site/kustomization.yaml +++ b/k8s/providers/hetzner/apps/business-site/kustomization.yaml @@ -3,5 +3,6 @@ kind: Kustomization resources: - tenant.yaml - cilium-network-policy-customer-identity-hold.yaml + - cilium-network-policy-dns-visibility.yaml - certificate.yaml - reference-grant.yaml diff --git a/scripts/check-business-disclosure-reader/main.go b/scripts/check-business-disclosure-reader/main.go index 9e3f3de1bb..39b4246ef7 100644 --- a/scripts/check-business-disclosure-reader/main.go +++ b/scripts/check-business-disclosure-reader/main.go @@ -24,6 +24,8 @@ func expectedPayload(kind string) string { return `{"path":{ "secret/data/apps/business-site/public-disclosure":{"capabilities":["read"]}, "secret/data/apps/business-site/smtp":{"capabilities":["read"]}, +"secret/data/apps/business-site/numina":{"capabilities":["read"]}, +"secret/data/apps/business-site/stripe":{"capabilities":["read"]}, "auth/token/lookup-self":{"capabilities":["read"]}, "auth/token/revoke-self":{"capabilities":["update"]}}}` default: diff --git a/scripts/tests/test-business-disclosure-reader.sh b/scripts/tests/test-business-disclosure-reader.sh index f6a51df306..3814f03c84 100755 --- a/scripts/tests/test-business-disclosure-reader.sh +++ b/scripts/tests/test-business-disclosure-reader.sh @@ -48,7 +48,7 @@ valid_policy() { } valid_role "${role}" || fail 'role must bind one exact identity and one read-only policy with a bounded lifetime' -valid_policy "${policy}" || fail 'policy must read only the selected disclosure and SMTP credential entries' +valid_policy "${policy}" || fail 'policy must read only the selected disclosure, SMTP credential and billing key entries' for kind in role policy; do if [ "${kind}" = role ]; then value="${role}"; else value="${policy}"; fi @@ -84,6 +84,11 @@ for change in \ '.path["secret/data/apps/business-site/other"] = {"capabilities": ["read"]}' \ '.path["secret/data/apps/business-site/smtp"].capabilities += ["update"]' \ '.path["secret/metadata/apps/business-site/smtp"] = {"capabilities": ["read", "list"]}' \ + '.path["secret/data/apps/business-site/numina"].capabilities += ["update"]' \ + '.path["secret/data/apps/business-site/stripe"].capabilities += ["create"]' \ + '.path["secret/metadata/apps/business-site/stripe"] = {"capabilities": ["read", "list"]}' \ + 'del(.path["secret/data/apps/business-site/numina"])' \ + 'del(.path["secret/data/apps/business-site/stripe"])' \ '.path["auth/token/*"] = {"capabilities": ["read", "update"]}' \ '.path["auth/token/lookup-self"].capabilities += ["update"]' \ 'del(.path["auth/token/revoke-self"])'; do @@ -96,4 +101,4 @@ grep -Fq "'scripts/tests/test-business-disclosure-reader.sh'" "${root_dir}/.gith grep -Fq 'bash scripts/tests/test-business-disclosure-reader.sh' "${root_dir}/.github/workflows/ci.yaml" || fail 'CI must execute this contract' -printf 'PASS: rendered business disclosure identity and 24 invalid-payload controls\n' +printf 'PASS: rendered business disclosure identity and 29 invalid-payload controls\n'