Super Admin console — deployment
Brouillon : cette page n'a pas encore été relue et peut être incomplète ou inexacte.
The Super Admin console is two apps, both submodules of this repo:
| App (manifest key) | Submodule / repo | Default branch | Image (DOCR) | Type |
|---|---|---|---|---|
super-admin-backend |
super-admin-backend/ (Django “orchestrator” API) |
master |
super-admin-backend |
backend: tag = <sha> |
super-admin-frontend |
DWN-SUPER-ADMIN/ (Next.js) |
main |
super-admin-frontend |
frontend: tag = <sha>-<env> |
They deploy through the same pipeline as GED/AFCM: app CI builds the image → bumps
environments/dev/versions.yaml → deploy.yml helm-upgrades agbale-<env>.
Staging/prod go through promote.yml. Before reviewing what the apps do, read
notes/superadmin-audit/super-admin-console-review.md; it lists known security
issues that are not fixed by this deployment work.
Topology
Section intitulée « Topology »https://admin.<env host>/ → super-admin-frontend (Next.js server, :3000)https://admin.<env host>/api/v1/* → super-admin-backend (gunicorn, :8000)https://<platform host>/auth → Keycloak (existing), realm `agbale`super-admin-backend → http://agbale-<env>-afcm-backend:80/internal/tenants (cluster DNS) → http://agbale-<env>-ged-backend:8000/internal/tenants → http://agbale-<env>-keycloak:8080/auth (JWKS, SA token, Admin API) → agbale-<env>-postgresql / super_admin_db- Own host, not a
/path. The console hard-codes root paths and has/auth/*routes that would collide with Keycloak’s/authon the platform host. A separate origin also keeps the platform-admin token away from any XSS in the tenant SPAs.global.superAdminDomainsets the host. - Only
/api/v1is routed to the backend./health,/api/schema/and/api/docs/stay cluster-internal, as does/internal/*on AFCM/GED. - TLS is issued by cert-manager’s ingress-shim into
<host>-tls. Don’t also add the host tocertificate.yaml: two Certificates on one secret fight, which is why dev already has a stuckdev-dowonou-com-tlsCertificate. - Database
super_admin_dblives on the shared Postgres. Fresh volumes create it in initdb. On existing volumes the migration Job’s init container creates it (agbale_userhas CREATEDB). - Migrations run in a post-install/upgrade Job, with
SKIP_MIGRATE=1on pods. Two CronJobs coverexpire_subscriptions(daily 00:15 UTC) andprocess_licence_outbox(every 5 min,concurrencyPolicy: Forbid). - NetworkPolicies (prod): pods labelled
dowonou.io/role=orchestrator(the API and the CronJobs) may reach backend pods on 80/8000, and nothing else is opened.
| Env | Console host | Keycloak authority | DNS |
|---|---|---|---|
| dev | admin.dev.dowonou.com |
https://dev.dowonou.com/auth |
✅ *.dev.dowonou.com wildcard |
| eph-N | eph-N-admin.dev.dowonou.com |
https://eph-N.dev.dowonou.com/auth (isolated KC) |
✅ wildcard |
| staging | admin.staging.dowonou.com |
https://staging.dowonou.com/auth |
❌ record needed |
| prod | admin.dowonou.com |
https://app.dowonou.com/auth |
❌ record needed |
The hosts are defined in two places that must agree: DWN-SUPER-ADMIN/.github/workflows/build-env.yml,
which bakes them into the image, and global.superAdminDomain in values-<env>.yaml.
Keycloak
Section intitulée « Keycloak »The console needs three realm objects. The realm export
(helm/agbale-platform/configs/keycloak-realm-export.json) carries them for
fresh Keycloaks (eph envs, new installs):
- Realm role
platform-admin: grants console access. It is not a tenantadmin. - Public client
dowonou-admin:- PKCE S256, standard flow only,
post.logout.redirect.uris=+. - Mappers: audience (
aud=dowonou-admin), realm roles, username/email/full name.
- PKCE S256, standard flow only,
- Confidential client
dowonou-orchestrator:- Service account holding
realm-managementrolesmanage-users,view-users,query-users,query-groups. - A realm-management client-role mapper.
- Service account holding
- Non-prod only: the test user
platformadmin(secrets.keycloakPlatformAdminUserPassword), with no tenant group.
The explicit mappers are required. This realm’s export defines its own
clientScopes, so a fresh import has no built-in roles/profile/email
scopes. Without the mappers the service-account token carries no resource_access
(the Admin API returns 403) and console tokens carry no email.
--import-realm never updates an existing realm. For dev/staging, run the
idempotent script once, then again whenever a host changes:
KC_PW=... # master admin (values-<env>.yaml keycloak.auth.adminPassword)ORCH_SECRET=... # must equal super-admin-backend.django.keycloak.saClientSecretGRANT_PLATFORM_ADMIN=<operator username> \ ./deploy/scripts/apply-super-admin-keycloak.sh \ https://dev.dowonou.com/auth agbale "$KC_PW" "$ORCH_SECRET" admin.dev.dowonou.com --dry-run# drop --dry-run to applySecurity note: manage-users is realm-wide, and the backend also forwards that
token to AFCM/GED (review finding SA-C1). Treat dowonou-orchestrator’s secret
like a realm admin credential.
One-time setup checklist (dev)
Section intitulée « One-time setup checklist (dev) »- Merge the superrepo PR. It adds the submodules, subcharts, realm export, eph workflow and dev manifest entries. The manifest change triggers a dev helm upgrade that only updates the realm and init-scripts ConfigMaps; no pods restart, and both console apps stay disabled because they are unpinned.
- Before merging, give the shared GitHub App access to both new repos. Two
workflows depend on it:
ephemeral-deploy.ymlchecks out all submodules recursively with the App token, so an App that can’t readsuper-admin-backend/DWN-SUPER-ADMINbreaks every eph deploy.promote.ymldispatchesbuild-env.ymlinDWN-SUPER-ADMIN.
- Add Actions secrets to both app repos, as on
ged_backend/agbale_frontend:DIGITALOCEAN_ACCESS_TOKEN(DOCR push),DEPLOY_APP_ID,DEPLOY_APP_PRIVATE_KEY. - Run
apply-super-admin-keycloak.shagainst dev (above), grantingplatform-adminto at least one operator. - Merge the app-repo PRs (Dockerfile + workflows). Each merge builds an image
and auto-merges a
deploy(dev): super-admin-* -> <tag>PR here, anddeploy.ymlenables the app on dev. - Smoke test:
https://admin.dev.dowonou.com/→ Keycloak login as the operator → dashboard. A tenantadminmust land on/interdit(403).
One-time setup checklist (staging)
Section intitulée « One-time setup checklist (staging) »The chart side is already in place: values-staging.yaml sets
global.superAdminDomain: admin.staging.dowonou.com, the orchestrator client secret
and both subchart blocks, and environments/staging/versions.yaml lists both apps
with an empty tag, so they stay disabled until promoted. CI needs no new workflow:
promote.yml rebuilds the frontend through DWN-SUPER-ADMIN’s build-env.yml
(staging host + https://staging.dowonou.com/auth baked in) and copies the backend
tag forward, and deploy.yml enables both apps when the promotion PR merges.
Before the first promotion:
- DNS: add an A record
admin.staging.dowonou.compointing to the ingress load balancer (the same IP asstaging.dowonou.com), unless a*.staging.dowonou.comwildcard already exists. cert-manager issuesadmin-staging-dowonou-com-tlson the first deploy once the record resolves. - Keycloak: run the script against the live staging realm. The secret must equal
super-admin-backend.django.keycloak.saClientSecretinvalues-staging.yaml:Fenêtre de terminal KC_PW=... # values-staging.yaml keycloak.auth.adminPasswordGRANT_PLATFORM_ADMIN=<operator username> \./deploy/scripts/apply-super-admin-keycloak.sh \https://staging.dowonou.com/auth agbale "$KC_PW" dowonou-orchestrator-secret-staging \admin.staging.dowonou.com --dry-run# drop --dry-run to apply - GitHub:
build-env.ymlruns in thestagingGitHub Environment ofDWN-SUPER-ADMIN. Make sureDIGITALOCEAN_ACCESS_TOKENis visible there (repo secret or Environment secret) and add required reviewers if staging builds should be gated. - Promote: Actions → Promote →
dev→staging, appssuper-admin-backend super-admin-frontend. Review and merge the PR;deploy.ymlruns the staging helm upgrade, the migration Job createssuper_admin_db, and the rollout is verified for both apps. - Smoke test:
https://admin.staging.dowonou.com/→ Keycloak login as the operator → dashboard. A tenantadminmust land on/interdit(403).
Known functional gaps at deploy time
Section intitulée « Known functional gaps at deploy time »- Organisation create / suspend returns 503 until AFCM and GED implement
PUT /internal/tenants(afcm-backend#130, ged_backend#53, both still open; see review findings RX-1…RX-6 before merging them). Each failed attempt still leaves a Keycloak group, and possibly a user, behind (review SA-H1). Don’t create real organisations on dev until that is resolved. - Module logos upload but are not served. The app has no
/mediaroute, and storage is a pod-local emptyDir (super-admin-backend.media.persistence). - Prod: add DNS,
global.superAdminDomain,super-admin-backendsecrets (django.secretKey,database.password,keycloak.saClientSecret) andsecrets.orchestratorKeycloakClientSecrettovalues-prod.yamlbefore promoting. Otherwise the whole env’s helm upgrade fails on the subchartrequiredchecks. Staging already has them (see below).
Validation performed when this was added (2026-09-14)
Section intitulée « Validation performed when this was added (2026-09-14) »- Images:
- Both built locally and run as non-root. The frontend runs on a read-only root
filesystem with security headers set and
/_next/imagedisabled. - Next upgraded 16.3.2 → 16.3.5;
npm audit --omit=devis clean.
- Both built locally and run as non-root. The frontend runs on a read-only root
filesystem with security headers set and
- Chart:
- Rendered for dev (apps off and on), eph and prod.
- With the apps off, dev differs from
mainonly in the realm and init-scripts ConfigMaps. - All 14 new resources pass
kubectl apply --dry-run=serveronagbale-dev.
- Keycloak 21.1 (the same version as dev), local:
- A fresh import of the new export works.
- The script applied to a
main-era realm is idempotent (a third run is a no-op). - The orchestrator service account can list and create
/tenants/*groups and users. platform-admintokens carryaud=dowonou-admin,typ=Bearer, email and roles.
- End to end, local: the backend image with chart-shaped env against the
fresh-import Keycloak and a stub adapter:
/api/v1/me: 401 with no token, 200 forplatform-admin, 403 for a tenantadmin.POST /organisationscreated the Keycloak group and pushed to both adapter URLs.