Files
infrastructure/group_vars/all/vault_matrix.yml
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

17 lines
1.2 KiB
YAML

$ANSIBLE_VAULT;1.1;AES256
61316633366534326163316234363463613733666565343866396637616136323266643534383362
3135623566336564643530333665663633613333306436610a363863336435333837306332623262
62303963636634396430343062663565316134336438356535376361643239313061343465346634
3561303761303665320a623236613435356163356438393234313964666434643135383733313264
37626366383533316230613732396130613233376634323336343236623133653961363461653739
39653030343432363834343864316530386366376664316532306336653936366562613232663437
36333362663738356362646338663563373633316335356634623361396364363230653636643738
63326636373762646634646563383235383038353566343339343431623866643334363262353337
63323565656263303631623661613664636637343363666331633664643639303064656135646165
32313234656231336138653131343262333833353961376431303536356436653435656361383036
38313962643335316365646533626364373438386366326130663063343439353761386234313561
63326533363133366339613838626464396138323333623036316431633862633436363239663362
30326635613366666633383364663634633163316431336231656638316564643736366565613033
63653933316136353932653333376633363630663130343035333432343939643062366430376435
643730656337656165633331343531396664