Commit Graph
2723 Commits
Author SHA1 Message Date
Quentin Gliech 808f63571b Upgrade opa-wasm to 0.2.0 to upgrade wasmtime
This fixes a bunch of RUSTSEC advisories, see https://github.com/element-hq/matrix-authentication-service/issues/5621
2026-04-13 18:10:19 +02:00
Eric Eastwood 594ab210a2 Add some docs for debugging policies 2026-04-09 16:19:17 -05:00
Quentin Gliech 856fb7aec3 build(deps): bump the opentelemetry group across 1 directory with 2 updates (#5567) 2026-03-31 13:18:52 +02:00
Quentin Gliech b0c878026e Use get_otel_context instead of accessing OtelData directly
`OtelData` is going to become private in a future version of
`tracing-opentelemetry`. Use the new `get_otel_context` function
introduced in 0.32.1 to extract the trace ID from the span context.
2026-03-31 12:24:08 +02:00
Quentin Gliech 551fce45b7 Fix scheduled jobs automatic cleanup not working in some conditions (#5574) 2026-03-31 12:05:33 +02:00
Eric Eastwood 7b02748af4 Explain code being splatted
See https://github.com/element-hq/matrix-authentication-service/pull/5553#discussion_r2984636426
2026-03-25 13:12:15 -05:00
Eric Eastwood 5a86084828 Merge branch 'main' into rei/violations_are_tagged 2026-03-24 16:42:47 -05:00
Quentin Gliech 42a2c37c5b Change queue_schedules FK to ON DELETE SET NULL
The cleanup-queue-jobs job was failing because it tried to delete
completed/failed jobs still referenced by `queue_schedules.last_scheduled_job_id`.
The FK defaulted to RESTRICT, blocking the delete.

Change it to `ON DELETE SET NULL` so cleanup can proceed, matching the
existing semantics (NULL = "never scheduled or cleaned up").

Fixes #5545
2026-03-24 11:44:23 +01:00
Quentin Gliech 9962146814 Do not check for the registration policy in case of an upstream OAuth 2.0 login that merges into an existing account (#5535) 2026-03-17 15:17:48 +01:00
Quentin Gliech 5800c4b34e Use recaptcha.net domain for Google reCAPTCHA (#5552) 2026-03-17 15:16:17 +01:00
Olivier 'reivilibre 1426ea4b22 Add support for locking to the mock homeserver and use in tests 2026-03-17 11:44:14 +00:00
Olivier 'reivilibre 9894564439 Convert ViolationCode into ViolationVariant to allow adding fields on each variant 2026-03-16 17:28:24 +00:00
Olivier 'reivilibre 5b7b4d61ec Schedule ProvisionUserJob after locking/unlocking user 2026-03-16 13:44:34 +00:00
Olivier 'reivilibre c2f72eccd1 Update ProvisionRequest with locked flag 2026-03-16 13:44:34 +00:00
shingyu 66c78727ac feat(recaptcha): change recaptcha endpoint 2026-03-15 18:18:14 +08:00
Jason Robinson a9276cd35c Move upstream OAuth2 link policy check
This moves the username policy check lower in the flow to fix
linking of locally existing user accounts with upstream accounts,
when on_conflict allows this, even if the registration policy
would disallow the user.
2026-03-03 21:57:08 +02:00
TonkkuandQuentin Gliech 77cd205026 Apply suggestion from @sandhose
Co-authored-by: Quentin Gliech <quenting@element.io>
2026-03-03 17:11:22 +02:00
Tonkku 673392fcc8 Support MSC4198 login_hint in account management uri 2026-02-23 13:06:59 +02:00
Quentin Gliech 86d5218ab2 Add a default Message-ID when sending emails (#5495) 2026-02-17 13:43:46 +01:00
Quentin Gliech 82e39a761d Comment what .message_id(None) means using lettre 2026-02-17 11:50:32 +01:00
Olivier 'reivilibre bac118ab12 Fix compat token refresh giving back a consumed token 2026-02-13 15:16:43 +00:00
Olivier 'reivilibre 94c97a5fed Add compat token refresh regression test 2026-02-13 15:16:43 +00:00
w0xel e84a7a9d8b Create default Message-ID for sent mail 2026-02-12 23:51:11 +01:00
matrixbot f6d6a20964 Automatic merge back to main (#5483) 2026-02-06 12:10:46 +01:00
Quentin Gliech c660127721 Use #[serde(other)] for unknown values instead of serde_with::DefaultOnError 2026-02-06 11:31:39 +01:00
Quentin Gliech 91c900588c Make the compat login SSO redirect query parameters ignore invalid values 2026-02-06 09:42:56 +01:00
Quentin Gliech 9d551c586d Split the database cleanup jobs and add a few tests for them (#5464) 2026-02-05 19:30:44 +01:00
Quentin Gliech c4c19d10a6 Remove unused code 2026-02-04 18:35:43 +01:00
Quentin Gliech b8eeee0eca Add a few tests for the cleanup jobs 2026-02-04 14:28:18 +01:00
Quentin Gliech d3d6c3dcd9 Split the cleanup jobs into multiple files 2026-02-04 12:12:28 +01:00
Quentin Gliech 24249811b4 Add syn2mas flag to ignore missing auth providers (#5451) 2026-01-29 11:23:17 +01:00
Jason Robinson 6a786dccbc Add syn2mas flag to ignore missing auth providers
Currently `syn2mas` will always error in the Synapse checks phase if it finds auth providers in the `user_external_ids` database table, that are not configured in Synapse config. While normally this the right thing to do, we may have situations where we know what we're doing, and want to ignore invalid looking data in the external identifiers table. If the flag is given, ignore errors and output them as warnings instead.
2026-01-26 14:57:31 +02:00
Quentin Gliech 378f24b118 Clear out last active IP on each sessions after 30 days (#5448) 2026-01-26 13:57:01 +01:00
Quentin Gliech dbdb2970ed Refactor inactive IP cleanup to use pagination
This should avoid dead many dead tuples when processing batches of
sessions to cleanup
2026-01-23 18:52:33 +01:00
Quentin Gliech b0e836eb44 Cleanup finished user/browser sessions (#5444) 2026-01-23 18:27:45 +01:00
Quentin Gliech 40cb5b0094 Cleanup finished OAuth 2.0 sessions (#5443) 2026-01-23 18:23:55 +01:00
Quentin Gliech f842f33a66 Re-enable the upstream authentication sessions cleanup job (#5439) 2026-01-23 18:17:11 +01:00
Quentin Gliech 8e6061bf04 Developer documentation about the various cleanup jobs (#5447) 2026-01-23 18:16:11 +01:00
Quentin Gliech af81a6cf78 Clean up leftovers in the database schema, part 2 (#5408) 2026-01-23 18:13:29 +01:00
Quentin Gliech 69f324e4e8 Clean up unsupported threepids from already deactivated users (#5407) 2026-01-23 17:42:46 +01:00
Quentin Gliech 5abc7f3f69 Include pagination params in the tracing fields of cleanup methods 2026-01-23 16:30:26 +01:00
Quentin Gliech 26caee7c99 Add cleanup jobs for inactive session IP addresses
This adds three new scheduled cleanup jobs that clear the last_active_ip
field from sessions that have been inactive for more than 30 days:

- CleanupInactiveOAuth2SessionIpsJob
- CleanupInactiveCompatSessionIpsJob
- CleanupInactiveUserSessionIpsJob

This helps with data minimization by not retaining IP addresses longer
2026-01-23 16:29:29 +01:00
Quentin Gliech 5bca9726b6 Add cleanup job for finished user sessions
Implements hard deletion of user/browser sessions that have been finished for more than 30 days, but only after all child sessions are cleaned up.

User sessions can only be deleted when no child sessions exist, ensuring backchannel logout propagation continues to work correctly.
2026-01-22 15:44:57 +01:00
Quentin Gliech 700007dbfd Fix FK constraint to preserve backchannel logout chain
Change compat_sessions.user_session_id FK from ON DELETE SET NULL to ON DELETE NO ACTION. This prevents deletion of user_sessions while compat_sessions still reference them, which is critical for backchannel logout propagation.

When an upstream IdP sends a backchannel logout, MAS must trace through:
  upstream_oauth_authorization_sessions -> user_sessions -> compat_sessions

If user_session_id links are SET NULL, logout propagation fails.

Uses two-step migration (DROP+ADD NOT VALID, then VALIDATE) to minimize table locking during deployment.
2026-01-22 15:44:57 +01:00
Quentin Gliech a66d652a70 Add cleanup job for finished OAuth2 sessions
Implements hard deletion of OAuth2 sessions that have been finished for more than 30 days, including their associated access and refresh tokens.
2026-01-22 15:44:56 +01:00
Quentin Gliech c29c4c3a5e Re-enable upstream OAuth session cleanup job
It should be safe to run now
2026-01-21 14:50:03 +01:00
Quentin Gliech 0486c6e05d Use the user_session_id on upstream authorisations for filtering instead
of authentications

This makes it one less table to read
2026-01-21 14:49:07 +01:00
Quentin Gliech c4c85978fe Add trigger and backfill for upstream OAuth user session tracking
Introduce a new trigger and a backfill migration to populate the
`user_session_id` column in `upstream_oauth_authorization_sessions`
based on `user_session_authentications`. This ensures historical data is
consistent and aids in backward compatibility.
2026-01-21 14:49:07 +01:00
Quentin Gliech 3834cbc105 Add index on the user_session_id foreign key for upstream auth sessions 2026-01-21 14:49:07 +01:00
Quentin Gliech 1bd11e7656 Disable cleanup of upstream OAuth sessions
This job is temporarily disabled due to pending database backfill work.
It will be re-enabled in a future release.
2026-01-21 12:28:19 +01:00