Operate the separate applicant realm
Applicants use opengov-applicants; agency staff use opengov. Citizens, residents, foreigners and personal representatives register with verified email. Eligibility belongs to each procedure. Accounts remain independent, including when their email addresses match.
Both realm imports are baked into the images. The new realm imports with registration closed and is reconciled independently by init-keycloak. Default deployment artifacts, Compose, Swarm and development select it for the portal (applicant_realm_enabled: true). Public registration remains closed (applicant_registration_enabled: false) until the mail and ingress checks below pass. Both realms are provisioned even when an existing deployment explicitly retains the legacy portal issuer. No staff clients, staff service account or seeded administrator are copied into it.
Before upgrading an existing deployment
- Take a backup with
scripts/backup.shand rehearse recovery in an isolated deployment. The bundle must containKEYCLOAK_CAPTURE.json,keycloak-realm.jsonandkeycloak-applicants-realm.json. Recovery metadata distinguishes complete live exports from configurations backed by the shared database snapshot. For an external Keycloak database, recovery of both identity populations must be completed separately before resuming traffic; staged realm files alone do not recover existing realms. - Inventory existing filings and all persisted vault owner columns. Application bootstrap refuses activation while any owner uses the historical unqualified account IDs. Inventory errors also refuse startup. This is a conservative, continuous guard: future records written under old IDs also require resolution before a restart. Do not reset a database, change an owner by email, or turn the flag off to bypass the inventory. A deployment with real old records needs a separately reviewed preservation/cutover plan; account migration is outside this change. Staff who apply personally use their separate applicant account. Once activated, personal wallet requests with staff credentials return 403 without creating data; staff self-filing and raw represented owner IDs are also refused. Authorized staff filing on behalf of a qualified applicant remains available.
- Configure SMTP credentials and delivery settings through the existing protected environment:
OPENGOV_SMTP_HOST,OPENGOV_SMTP_FROM, port, transport and optional paired user/password. The authenticating Keycloak administrative account must have an email address for Keycloak’s SMTP connection test. KeepOPENGOV_APPLICANT_REGISTRATION_ENABLED=falsewhile checking delivery. The reconciler opens registration only after SMTP configuration and Keycloak’s test message succeed. Successful configuration does not prove the mail provider delivers messages. - Check the installed proxy limits before opening registration. These requests reach Keycloak directly and bypass the application limiter.
Check the proxy limits
Default Compose and Swarm deployments install the limits through labels on the login service.
Provisioning derives the bare login host, OIDC_PROXY_HOST, from the deployment artifact.
Provisioning also preserves Compose variables in Coolify labels.
Dedicated public routes keep path-specific middleware off normal sign-in requests.
The labels define the applicant limits and refuse the public admin paths.
The routes survive container replacement and preserve the separate staff routes.
For an older deployment, reprovision with the current deployment files. Remove older file-provider routes after the labels take effect because those routes can retain an obsolete backend address.
To repair an older deployment before its next deploy, render an additive Traefik 3 configuration:
python scripts/render_applicant_auth_limits.py deployments/<code> \
--backend-url http://<identity-container-on-proxy-network>:8080 \
--output /tmp/applicant-auth.yaml
Check the generated host, backend address, https entry point and letsencrypt resolver against the deployment’s proxy.
Install the repair file in the proxy’s watched file-provider directory.
The proxy must reach the chosen backend on the deployment’s Docker network.
Use the exact backend address because another deployment can also name its login service oidc.
Remove this repair file after the deployment labels take effect.
Keep backend ports private so public requests cannot bypass the limits.
Traefik instantiates counters per router, including when middleware names match. Each of the three applicant routers receives 33 requests/second, 16 in flight and 20 requests/minute per connection peer. Across all three routers the combined ceiling is therefore 99 requests/second, 48 in flight and 60 requests/minute per peer, with separate initial bursts. Registration POSTs also receive 10/10 minutes per peer; recovery POSTs and all required-action GET/POSTs receive 5/10 minutes per peer. The required-action budget covers verification resend and credential setup, regardless of query parameters. Path prefixes include trailing-slash and matrix suffix variants, so alternate identity-server paths cannot select the looser general route. Every route applies both its own aggregate and peer budget; these are independent counters, not one shared counter. Peer keys use the actual connection address and ignore caller-supplied forwarded headers. When another proxy fronts Traefik, many people may share one peer budget; resolve that topology and tune measured shared-network needs before activation. Multiple proxy replicas multiply the allowance; these controls do not implement a distributed mail quota or bot challenge.
Through the public login host, verify that repeated POSTs to /realms/opengov-applicants/login-actions/registration and /login-actions/reset-credentials, and GET/POSTs to /login-actions/required-action, receive 429 at their dedicated budgets. Repeat those checks with trailing slashes and path parameters, and with an omitted or changed required-action execution query. Changing X-Forwarded-For must not reset the allowance. Check the existing staff realm still signs in. Also inspect aggregate/concurrency enforcement and attempts to bypass the proxy through every externally reachable address. Use disposable accounts and suppress unintended mail delivery during the abuse rehearsal. Watch refusal rates and delivery failures without recording credentials or action-token links.
Activate and verify
New artifacts already set applicant_realm_enabled: true and applicant_registration_enabled: false. Existing deployments with unresolved historical ownership must explicitly retain applicant_realm_enabled: false until a reviewed preservation/cutover plan is complete; this keeps the old portal issuer while still provisioning and backing up both realms. Reprovision the artifact-derived environment. Compose also accepts the corresponding OPENGOV_APPLICANT_REALM_ENABLED and OPENGOV_APPLICANT_REGISTRATION_ENABLED values. The derived applicant issuer is https://login.<wildcard_base>/realms/opengov-applicants and audience is opengov-applicant-api; development or external identity hosting must supply its exact issuer and optional OPENGOV_APPLICANT_OIDC_JWKS_URL. Preserve the separate staff issuer and audience.
Check app/worker startup and realm reconciliation, then public discovery and /config.json on every component host. Only the applicant portal selects the new issuer. Its protected /api/v1/platform/session response supplies the canonical ownership ID; raw OIDC subjects are never applicant ownership keys. Run scripts/smoke_deployment.py for the artifact: it checks both realms by default and derives the portal issuer from the artifact. The automated scripts/post_deploy_smoke.py checks both realms and expects the applicant portal issuer by default; an existing deployment retaining its legacy portal issuer must explicitly use --no-applicant-realm-enabled.
After mail, proxy and recovery checks pass, set applicant_registration_enabled: true, reprovision and verify that reconciliation succeeded. Exercise branded sign-up and verification, initial password setup, return to a procedure, draft save/resume and submission, recovery, and account switching with two applicants. Confirm neither applicant can access the other’s private data, staff authoring/directory/rights/payment reconciliation, or the staff assistant door. Unverified applicants receive 403 from protected applicant APIs. Tokens must name the exact applicant issuer, API audience and authorized client opengov-portal; email verification establishes email control, not nationality or legal identity.
Close registration or recover
To stop new accounts, set applicant_registration_enabled: false and reprovision/reconcile. Keep applicant_realm_enabled: true so existing applicants retain login, recovery and access to their filings. Confirm the register link disappears and an existing account can still sign in. Turning the realm flag off changes the portal issuer and refuses its tokens; it is not a safe rollback after applicants have created records. Preserve the realm, exact issuer URL, namespace, keys and data while rolling back software. Changing the issuer changes canonical applicant ownership and requires a separate preservation plan. There is no routine account linking, transfer or email-based reassignment.
The two realms share one Keycloak process/database and administrative boundary. Separate policies and keys do not isolate a server failure or a database compromise. Self-service account deletion remains disabled until coordinated application retention/erasure is supported for this realm.