Files
Jan Alexander Steffens (heftig)andAntigravity 5e461e81b3 matrix: Add matrix-authentication-service
Staff Role Restriction (Keycloak)
---------------------------------

Because matrix-authentication-service lacks an equivalent to Synapse's
attribute_requirements (and claims_imports only runs during initial
registration/linking, so it would not block offboarded users on later
logins), enforce the Staff role requirement directly in Keycloak before
any OIDC tokens or client sessions are issued:

- Add a `staff_only` client scope (`include_in_token_scope = false`) and
  attach it as a default scope on `openid_matrix_mas` so users cannot
  strip it from the authorization request.

- In `Arch Browser`, wrap Cookie, Identity Provider Redirector, and
  Password+2FA in a REQUIRED `Browser Auth Subflow`, followed by a
  CONDITIONAL `Browser Staff Role Check Subflow` combining
  `conditional-client-scope` (`staff_only`), `conditional-user-role`
  (`Staff`, negated), and `deny-access-authenticator`. Wrapping the auth
  steps ensures SSO cookie reuse still hits the role check.

- In `Arch Post IPR Flow`, wrap the 2FA steps in a REQUIRED `IPR 2FA
  Subflow` and add the same conditional check (`IPR Staff Role Check
  Subflow`), since GitHub broker logins skip the rest of the browser
  flow. Non-Staff users can still sign into other clients via GitHub
  while being denied access to `openid_matrix_mas`.

Cutover Checklist
-----------------

1. Run `terraform init && terraform apply` in tf-stage1 (DNS for
   auth.matrix.archlinux.org) and tf-stage2 (Keycloak flows, scope, and
   openid_matrix_mas client).
2. Run the playbook tags/steps up to installing
   matrix-authentication-service, creating the mas DB, rendering
   /etc/matrix-authentication-service/config.yaml, and migrating the MAS
   DB (`mas-cli database migrate`), or deploy with Synapse stopped while
   migrating.
3. Stop synapse.service (and workers), run `mas-cli syn2mas check` and
   `mas-cli syn2mas migrate --dry-run` (checking
   /etc/matrix-authentication-service/config.yaml and
   /etc/synapse/homeserver.yaml before homeserver.yaml removes
   `oidc_providers`), then run the live `mas-cli syn2mas migrate`.
4. Run playbooks/matrix.archlinux.org.yml to switch homeserver.yaml,
   reload nginx, and start synapse + matrix-authentication-service
   + matrix-authentication-service-worker.
5. Test login with a Staff account and verify non-Staff accounts are
   denied via password+2FA, existing Keycloak SSO cookie, and GitHub
   broker login.

Co-Authored-By: Antigravity (Gemini 4 Neon) <noreply@google.com>
2026-11-29 01:20:03 +01:00

7 lines
204 B
YAML

matrix_domain: "matrix.archlinux.org"
matrix_auth_domain: "auth.matrix.archlinux.org"
matrix_openid_mas_client_id: 01JRBSDQHEHVFY5A90E0R822C6
# Same as archweb_domain
matrix_server_name: "archlinux.org"