Aller au contenu

GED → `/ged` routing + RBAC backend — coordinated rollout

Brouillon : cette page n'a pas encore été relue et peut être incomplète ou inexacte.

Runbook for shipping the GED path-standardization together with the GED RBAC backend it depends on. Read this before promoting to any environment.

The /ged frontend build (agbale_frontend main, PR agbale_frontend#24) contains two coupled changes:

  1. Base path — the SPA is built for /ged (VITE_BASE_PATH=/ged) and calls its API at /ged/api.
  2. RBAC menu — the left menu is permission-gated. The frontend loads the user’s roles/permissions from GET /api/me/. Those come from the Keycloak → RBAC role sync that only exists in the newer ged_backend.

If you deploy the new GED frontend without the RBAC backend, GED breaks in two visible ways (both observed on the ephemeral test env before the backend was bumped):

  • The header shows a generic “Utilisateur” instead of the logged-in user (/api/me/ → 404 on the old backend).
  • The left menu collapses to just Tableau de bord + Paramètres (no permissions → every gated item hidden).

SSO itself is unaffected — the routing works; this is purely a frontend/backend version-contract mismatch.

Component Ship Notes
dowonou-deploy PR #53 ingress /ged rewrite, portal at /, ged-backend FRONTEND_URL=https://<domain>/ged/login, Keycloak /ged/* redirects
agbale_frontend PR #24 → main VITE_BASE_PATH=/ged; already carries the RBAC menu code
ged_backend ≥ 1b82a2c (PR #20) must include the RBAC feature (see below)

Dev already runs an RBAC-capable ged_backend (7a036fb, a descendant of 1b82a2c, with /api/me/ and the KC→RBAC sync) and an RBAC-aware ged-frontend (bc6a47d, root build). So on dev no backend/frontend capability bump is needed — the pending change is purely the routing (/ged ingress + portal + FRONTEND_URL=/ged/login) plus the /ged frontend build. For staging/prod, verify their ged_backend is ≥ 1b82a2c before deploying the /ged frontend there; bump if not.

Required ged_backend commits (all in 1b82a2c):

  • b7eb1f1 — sync Keycloak roles → RBAC at login
  • 0fad67a — fetch Keycloak roles via userinfo / id_token
  • 1b82a2c (PR #20) — default “Utilisateur” full-access permissions
  • adds MeView → GET /api/me/ returning roles + permissions

The RBAC backend adds four migrations; the container entrypoint runs python manage.py migrate --no-input on startup:

  • 0003_rbac_roles_permissions — create RBAC tables
  • 0004_seed_rbac — seed roles + permissions
  • 0005_assign_admin_role_to_existing_users — grant admin to privileged existing users
  • 0006_alter_activitylog_rbac_choices — AlterField on activitylog (app-level choices)

Observed: dev’s shared agbale_ged_db is already migrated to RBAC — a clone of dev’s DB + migrate reported “No migrations to apply”. This is expected: dev already runs the RBAC backend (7a036fb), which applied 0003–0006 when it was deployed. So on dev the migration step is a no-op.

On staging/prod the migration will run for the first time — it creates tables, seeds, and assigns admin to existing privileged users. Take a DB backup first.

Client agbale-ged needs the /ged redirect URI + web origin on each realm:

  • Fresh realms — already in the realm-export files (PR #53: deploy/docker/keycloak/realm-export.json, helm/agbale-platform/configs/keycloak-realm-export.json).
  • Existing realms (dev/staging/prod) — add at runtime:
    ./deploy/scripts/preview-keycloak.sh add <domain> agbale-ged <kc_admin_pw>
    (adds https://<domain>/*, which covers /ged/*), or add https://<domain>/ged/* + web origin https://<domain> via the admin console.

FRONTEND_URL = https://<domain>/ged/login (set by PR #53) is GED’s redirect_uri source and must be an allowed redirect on agbale-ged.

  1. Back up the GED DB (staging/prod — first-time migration).
  2. Add the agbale-ged /ged/* redirect URI on that env’s Keycloak.
  3. Build the GED frontend for the env with VITE_BASE_PATH=/ged (via build-env, #24).
  4. In environments/<env>/versions.yaml, bump ged-backend (→ RBAC image) and ged-frontend (→ /ged build) in the same change.
  5. helm upgrade the #53 chart. The backend entrypoint applies migrations (no-op on dev; first-time on staging/prod).
  6. Smoke test (below).
  7. Communicate the URL change (GED moves to /ged; old root deep links stop working) before prod.
  • https://<domain>/ → the app-chooser portal (GED + AFCM cards).
  • https://<domain>/ged → GED loads (/ged/assets/… 200); SSO round-trips back to /ged; header shows the real user (not “Utilisateur”).
  • GET /ged/api/me/ returns roles + permissions; the menu matches the user’s role (admin → full menu).
  • https://<domain>/afcm → AFCM unaffected.
  • Old root GED URLs no longer serve GED (clean cutover).
  • Routing: revert #53, repoint ged-frontend to the root build, remove the /ged redirect URIs.
  • RBAC backend: a code/image rollback is safe — migrations stay applied and the old code simply ignores the RBAC tables (this is exactly dev’s current state). No DB rollback needed for a code rollback.

The combined change was validated end-to-end on https://route-test.dev.dowonou.com (portal at /, GED at /ged, AFCM at /afcm), using an isolated GED database cloned from dev + the RBAC backend — so dev was never mutated. Teardown: notes/route-test-teardown.sh.