Commit Graph
2978 Commits
Author SHA1 Message Date
Quentin Gliech 13d10dfe7e Adapt to the sd-notify 0.5 API changes
`notify()` lost its `unset_env` argument, and `watchdog_enabled()` now
returns an `Option<Duration>` directly.
2026-07-02 22:22:51 +02:00
Quentin Gliech 92318fc368 Upgrade aide, schemars and axum (#5752) 2026-07-02 17:43:41 +02:00
Quentin Gliech a62a9ebdeb Fix the HTTP client not setting the ALPN extension (#5758) 2026-07-02 12:11:09 +02:00
Quentin Gliech 7d249dccb9 Upgrade ICU crates to 2.x (#5761) 2026-07-02 12:09:49 +02:00
Quentin Gliech 4912a36888 admin: keep generic response schema names stable under schemars 1.0
schemars 1.0 dropped the type parameter from a generic's default schema name
(SingleResponse_for_User -> SingleResponse with numeric dedup like
SingleResponse2/3...). Those names become the OpenAPI $defs keys and, downstream,
the generated TypeScript type names in element-admin's SDK — so the change both
renamed every wrapper type and made the names positional/unstable.

Restore the 0.9 '_for_T' naming via schemars 1.0's rename format string on the
three generic wrappers (SingleResponse/PaginatedResponse/SingleResource), keeping
the published admin API schema stable for consumers.
2026-07-01 17:09:26 +02:00
Quentin Gliech 98d1ac399e Port the remaining icu4x call sites to 2.0 2026-07-01 17:07:49 +02:00
Quentin Gliech 7dd04bb691 i18n: port the translator to the icu4x 2.0 API
Use the icu_locale fallbacker with a default LocaleFallbackConfig, build
PluralRules and the RelativeTimeFormatter from compiled data, format times with
the fieldset-based NoCalendarFormatter, and adopt the new data-error model
(IdentifierNotFound / MarkerNotFound).
2026-07-01 17:07:49 +02:00
Quentin Gliech b8aaa1a980 deps: upgrade icu4x 1.5 -> 2.2
Bumps all the ICU related dependencies to 2.2 or equivalent
2026-07-01 17:07:49 +02:00
Quentin Gliech b74ac42018 Install the rustls crypto provider in the handlers test setup
Building the HTTP client now relies on a process-level rustls crypto
provider being installed (we no longer pass a pre-configured TLS config
that bundled one). Tests going through TestState that didn't call
setup() — e.g. the login_sso_redirect tests — panicked when building the
client. Call setup() from from_pool_with_site_config so every TestState
installs the provider.
2026-06-30 12:18:47 +02:00
Quentin Gliech 938c6aee67 Do not customize the TLS configuration of the HTTP client
This fixes a bug where we were not sending the ALPN extension, which caused the
HTTP client to always use HTTP/1.1 instead of HTTP/2.

Fixes #5757
2026-06-30 12:18:47 +02:00
Quentin Gliech f7e2fd2803 Record the HTTP version in the HTTP client trace
As per the OTEL semantic conventions:
https://opentelemetry.io/docs/specs/semconv/http/http-spans/
2026-06-30 12:18:46 +02:00
Quentin Gliech f948dec457 config: remove the unused branding.logo_uri option
branding.logo_uri was accepted and validated by the config layer but never
plumbed through to SiteConfig or any template, so it had no effect. Remove the
field and regenerate the committed config schema to remove the confusion.
2026-06-25 19:04:19 +02:00
Quentin Gliech 1d1bcbaf26 cli: clean up the doctor homeserver checks
MSC2965 changed the discovery mechanism to stop relying on .well-known
documents a while back. We removed references to this in the configuration
manual some time ago (see e3d1b8abfa) but
`mas-cli doctor` was still checking for it.

See element-hq/backend-internal#5 as well
2026-06-25 19:04:18 +02:00
Quentin Gliech 5d489f71e9 Infer an initial name for the device for the device auth grant (#5750) 2026-06-25 18:34:46 +02:00
Quentin Gliech a51e222d49 Track and log database statistics for every request and job (#5745) 2026-06-25 18:26:09 +02:00
Quentin Gliech b76f08cf86 deps: upgrade sea-query to 1.0, switch sea-query-binder -> sea-query-sqlx (#5744) 2026-06-25 16:45:37 +02:00
Quentin Gliech 1283932c35 Infer a device name for the device authorization grant
Mirror the authorization code grant: render a human-readable device name
from the client and the polling device's user-agent, using the locale
captured on the grant, and provision it on the homeserver instead of
sending no display name.
2026-06-23 10:26:08 +02:00
Quentin Gliech 401b1e299b Persist the browser locale on the device code grant
Capture the preferred language from the browser view which accepts the
device code grant and store it on the grant, so it can later be used to
render a human-readable device name.
2026-06-23 10:26:07 +02:00
Quentin Gliech 6491ded8c1 Migrate all the ULID generations to use the extension trait 2026-06-22 14:46:55 +02:00
Quentin Gliech 6b390a3d5d Introduce an extension trait to generate ULIDs with our own datetime and randomness
This adds a new trait to help generate ULIDs with `chrono::DateTime` and the
workspace-level `rand` crate. This is to help decouple `rand` and `ulid`
upgrades from  each other.
2026-06-22 14:46:55 +02:00
Quentin Gliech d84fd87517 mas-storage-pg: record SQL and DB stats at the executor layer
Swaps ExecuteExt to return a Traced<Q> wrapper whose fetch_*/execute
methods run the query through the RecordingExecutor, replacing the old
blanket impl that only recorded db.query.text. Adds the per-query-type
Traced<T> impls and the supporting test.
2026-06-22 14:43:05 +02:00
Quentin Gliech a0897ac71a mas-storage-pg: add a recording SQL executor and stream
Introduces a RecordingExecutor (an sqlx Executor wrapper) and the
RecordingStream it returns, which record the SQL as db.query.text and
accumulate per-context query count/timing.
2026-06-22 14:43:05 +02:00
Quentin Gliech 44c834bc45 mas-context: track cumulative DB query count and time on LogContext
Add db_queries / db_time / db_rows_fetched / db_rows_affected counters to
LogContext, mirroring Synapse's LoggingContext db_txn_count / db_txn_duration_sec.

They are exposed through LogContextStats and its Display, so they appear
automatically in the existing HTTP request-completion and job-completion log
lines.
2026-06-22 14:43:05 +02:00
Quentin Gliech b714fdf870 deps: upgrade sea-query to 1.0, switch sea-query-binder -> sea-query-sqlx
Prepares for the sqlx 0.9 upgrade: sea-query-binder is pinned to sqlx 0.8,
and its sqlx-0.9 successor is the renamed sea-query-sqlx crate which requires
sea-query 1.0. This change does the sea-query 0.32 -> 1.0 major migration while
staying on sqlx 0.8 (via sea-query-sqlx 0.8.1), to keep it decoupled from the
sqlx bump itself.
2026-06-19 10:40:12 +02:00
Quentin Gliech fc798b2831 mas-axum-utils: move the RecordAsRequester doc comment onto its method
Addresses review feedback on #5735: the doc describing
`maybe_record_as_requester` belonged on the method, not the trait.
2026-06-18 13:43:59 +02:00
Quentin Gliech e42d85d14e Merge branch 'main' into the requester logging branch 2026-06-18 13:43:59 +02:00
Quentin Gliech e4157b4b02 Log the GraphQL operation type and name (#5736) 2026-06-18 13:34:55 +02:00
Quentin Gliech e0c03b06e8 deps: upgrade reqwest 0.13, sentry 0.48, opentelemetry 0.32
We need to group the sentry and opentelemetry bumps together because they both
upgraded reqwest to 0.13.

- reqwest 0.12 -> 0.13: rename the rustls feature to rustls-no-provider,
  add the now-opt-in 'form' feature.
- sentry 0.46 -> 0.48: add rustls-no-provider so Sentry's reqwest 0.13
  transport reuses our process-wide aws-lc-rs provider.
- opentelemetry 0.31 -> 0.32 / tracing-opentelemetry 0.33: update the
  get_otel_context call in mas-context for the new signature.

opentelemetry-jaeger-propagator 0.32 is deprecated upstream but still
published; we keep it for now (with an expect(deprecated)) and will
vendor it in-tree once it's actually removed.
2026-06-17 19:00:25 +02:00
Quentin Gliech 269c1d9caf Merge branch 'main' into the requester logging branch 2026-06-17 17:57:16 +02:00
Quentin Gliech 9133820368 Merge branch 'main' into the GraphQL logging branch 2026-06-17 17:57:16 +02:00
Quentin Gliech a2533cd3f3 Track and log the client IP address (#5734) 2026-06-17 17:45:06 +02:00
Quentin Gliech fe622331a8 Admin API: allow listing and viewing of OAuth 2.0 clients (#5710) 2026-06-17 17:44:34 +02:00
Quentin Gliech 78036a933d Fix the compat session API definition in the admin API spec (#5714) 2026-06-17 17:42:31 +02:00
Quentin Gliech 256c5e3ff5 storage: use an enum for the OAuth2ClientFilter client kind 2026-06-17 17:33:03 +02:00
Quentin Gliech d33577cf4d Admin API: filter users based on client usage (#5707) 2026-06-17 17:12:56 +02:00
Quentin Gliech 9464ca8038 Merge branch 'main' into quenting/admin-api/session-time-filters 2026-06-17 17:01:02 +02:00
Quentin Gliech a8ffce8f13 Admin API: allow filtering OAuth 2.0 sessions by multiple clients (#5708) 2026-06-17 16:40:53 +02:00
Quentin Gliech d951d0eed5 Remove special case for the empty client filter 2026-06-17 15:15:09 +02:00
Quentin Gliech eb0ef6380c Merge branch 'main' into quenting/upstream-pass-parameters 2026-06-17 14:54:37 +02:00
Quentin Gliech 772360bb4e Trim values before passing them to the upstream auth provider 2026-06-17 14:53:56 +02:00
Olivier 'reivilibre 0b80e523f5 Trim value when reading client_secret_file (#5456) 2026-06-17 13:37:13 +01:00
Quentin Gliech 9e60371aeb mas-cli: log the requester on the request log line
Add `requester=...` to the `http.server.response` log line, reading the
`Requester` recorded on the request's `LogContext`.
2026-06-17 14:14:24 +02:00
Quentin Gliech 98106df25a mas-cli: log the GraphQL operation on the request log line
Read the `GraphQlOperation` set by the GraphQL handler from the response
extensions in the logging middleware, and record the operation type and name
on the `http.server.response` log line when present.
2026-06-17 14:14:24 +02:00
Quentin Gliech 31b0b208c0 Record the client address on the HTTP request span 2026-06-17 14:14:24 +02:00
Quentin Gliech b14ad9af59 mas-handlers: expose the GraphQL operation on the response extensions
Define a `GraphQlOperation` type holding the operation type and name, and
attach it to the GraphQL response via the response extensions, so the HTTP
logging middleware can pick it up. The operation type is resolved from the
parsed query document, which is cached on the request and reused by the
executor.
2026-06-17 14:14:24 +02:00
Quentin Gliech be257bf683 mas-handlers: record the requester at the remaining auth sites
Record the requester for the admin API, GraphQL, the compat
login/logout/logout_all/refresh endpoints, and the OAuth2 token (the
authenticated client) and introspection (the introspecting client, or the
homeserver) endpoints. Introspection records the caller, never the subject
of the introspected token.

The request test helper now runs each request inside a `LogContext`, with
a helper to assert the recorded requester.
2026-06-17 14:14:23 +02:00
Quentin Gliech 4cea9320d1 Track the client IP address for the whole request and log it 2026-06-17 14:14:23 +02:00
Quentin Gliech 715d516430 mas-axum-utils: record the requester at shared auth points
Add a `RecordAsRequester` trait mapping domain types (User, BrowserSession,
OAuth2 Session, CompatSession, Client) to a `Requester`, and record it from
the two shared auth-resolution points: `SessionInfo::load_active_session`
(browser sessions) and `AccessToken::fetch` (OAuth2 bearer tokens).
2026-06-17 14:14:23 +02:00
Quentin Gliech c6cd294777 mas-context: add a Requester to the LogContext
Add a `Requester` enum (a user, an OAuth2 client, or the homeserver) stored
in a set-once slot on the `LogContext`. This lets request handlers record
which entity authenticated a request so it can be logged later.
2026-06-17 14:14:23 +02:00
Olivier 'reivilibre c857375528 Update crates/config/src/sections/mod.rs 2026-06-17 12:45:30 +01:00