WIP: act as a Matrix OIDC auth provider #810

Draft
lafleur wants to merge 60 commits from lafleur/continuwuity:as-oidc-provider into main

60 commits

Author SHA1 Message Date
1340251362
chore: Fixup (satisfy CI)
Some checks failed
Documentation / Build and Deploy Documentation (pull_request) Has been skipped
Update flake hashes / update-flake-hashes (pull_request) Successful in 13s
Checks / Prek / Pre-commit & Formatting (pull_request) Successful in 2m11s
Checks / Prek / Clippy and Cargo Tests (pull_request) Failing after 11m47s
2025-12-10 21:56:23 +00:00
4dc537379d add some docstrings
Some checks failed
Documentation / Build and Deploy Documentation (pull_request) Has been skipped
Update flake hashes / update-flake-hashes (pull_request) Successful in 13s
Checks / Prek / Clippy and Cargo Tests (pull_request) Has been cancelled
Checks / Prek / Pre-commit & Formatting (pull_request) Has been cancelled
2025-12-10 21:54:48 +00:00
b692f61c31 update TODO tags 2025-12-10 21:54:48 +00:00
3f02d1c0ff move OidcEndpoint to its separate source file 2025-12-10 21:54:48 +00:00
e6d9acd49f chore: run cargo fmt 2025-12-10 21:54:48 +00:00
2aa2a80481 add docstrings 2025-12-10 21:54:48 +00:00
bfb162c907 OidcIssuer: add debug logs 2025-12-10 21:54:48 +00:00
90443f09b2 remove failing and useless test 2025-12-10 21:54:48 +00:00
99720a4298 chore: run cargo +nightly fmt 2025-12-10 21:54:48 +00:00
7918ff07c8 move endpoint to oidc crate, reorganize 2025-12-10 21:54:48 +00:00
f5826b5b84 typos 2025-12-10 21:54:48 +00:00
578d44672b chore: run cargo +nightly fmt 2025-12-10 21:54:48 +00:00
70cdb5f865 OIDC: use async auth flows 2025-12-10 21:54:48 +00:00
605be506d2 chore: cargo +nightly fmt 2025-12-10 21:54:48 +00:00
984b7c5668 OIDC: reimplement using rocksdb and oxide-auth-async
devices and their tokens use the global registries and services::users commands,
and some db registries are added :
- clientid_oidcclient (stores OIDC client details)
- oidcdeviceid_grant (stores oxide-auth grant details)
- refreshtoken_userdeviceidexpiresat (stores refresh tokens' expiry date)
- userdeviceid_oidcdevice (stores OIDC device details)

This implementation lacks the owner consent dialog. This will be addressed in
a future commit.
2025-12-10 21:54:48 +00:00
d6317af611 OIDC: improve web templates
- fixes CSP issues with localhost
- better consent message
-use askama urlencode_strict
2025-12-10 21:54:48 +00:00
568853b900 registrar: fix error type on deser error 2025-12-10 21:54:48 +00:00
dab89d561c impl persistent tokens + MSC4254 (token revoke)
adds an "issuer_secret" to config.auth that lets the issuer persist tokens
between continuwuity restarts
2025-12-10 21:54:48 +00:00
9461fb18f4 chore: Update Cargo.lock 2025-12-10 21:54:48 +00:00
77422cebbb chore: Fix template EOFs 2025-12-10 21:54:48 +00:00
9a133ba7ee chore: Clippy and formatting 2025-12-10 21:54:48 +00:00
72879daf28 fix accidental project name regression 2025-12-10 21:54:48 +00:00
418b5d8a5f OIDC: fix build after rebase 2025-12-10 21:54:48 +00:00
9c475b2992 OIDC: impl client_registrar over db (sync impl) 2025-12-10 21:54:48 +00:00
0f03909b19 OIDC auth flow: correct device registration 2025-12-10 21:54:48 +00:00
f37f169934 OIDC private clients: correct client secret 2025-12-10 21:54:48 +00:00
0258fd3fa4 unlimit log levels and update Cargo.lock 2025-12-10 21:54:48 +00:00
6818cf462b oidc: implement registering devices 2025-12-10 21:54:48 +00:00
2b13a2c603 WIP: show discrepancy between device_id and client_id 2025-12-10 21:54:48 +00:00
df290c1013 add services::oidc::user_and_device_from_token(), use in auth 2025-12-10 21:54:48 +00:00
534aabe3f7 OIDC: embed user_id in consent 2025-12-10 21:54:48 +00:00
db3c7abe3a web::login: add form-data CSP rules for localhost 2025-12-10 21:54:48 +00:00
ad37af26b8 add some OIDC docstrings 2025-12-10 21:54:48 +00:00
592c06f738 fix oxide-auth's redirect_uri comparison
oxide-auth's `RegisteredUrl::IgnorePortOnLocalhost` doesn't work when the host is 127.0.0.1 or [::1].
This commit lets the authentication process translate the host. The new registrar already supports this.
2025-12-10 21:54:48 +00:00
69bffe2894 basic OIDC client registrar with auth tracing 2025-12-10 21:54:48 +00:00
05b04526c7 OIDC: make response_mode optional
Fractal omits the `response_mode` field when in an auth flow (its value must be
the literal "S256", so it's mainly here for OIDC compliance I guess). Accepting
this lets it proceed to the next authentication step.
2025-12-10 21:54:48 +00:00
8df5647346 support OIDC private clients 2025-12-10 21:54:48 +00:00
ffbed9835e oidc: add debug/trace logs 2025-12-10 21:54:48 +00:00
d8e2cce6da oidc authorize: make response_mode optional 2025-12-10 21:54:48 +00:00
0231659d5c fix build warning : explicit cast 2025-12-10 21:54:48 +00:00
82279aed73 fix build errors 2025-12-10 21:54:48 +00:00
06072080c0 fixup! fix OidcResponse: reimplement IntoResponse 2025-12-10 21:54:48 +00:00
d96ddf5cb1 fix OidcResponse: reimplement IntoResponse 2025-12-10 21:54:48 +00:00
48e283d86d chore: fix up 2025-12-10 21:54:48 +00:00
a5925327fd oidc: small cosmetics + typos 2025-12-10 21:54:48 +00:00
fcabdac87e remove stale debugging logs
I don't have the hd space to do debug builds, so I use tracing::info to debug
on release builds. Silly, right ?
2025-12-10 21:54:48 +00:00
6dbfef5b62 use config.server_name as title in OIDC pages 2025-12-10 21:54:48 +00:00
d284dffc47 fix oidc_provider discovery message and docstrings 2025-12-10 21:54:48 +00:00
11d3855fa7 typos oidc_provider discovery 2025-12-10 21:54:48 +00:00
f6c5231fb6 fix oidc_provider config section's doc generation 2025-12-10 21:54:48 +00:00
5a48ce44bb fix: Don't crash when the client URL doesn't have a domain
Having a URL with an IP literal, for example, is allowed
2025-12-10 21:54:48 +00:00
25f051b1d8 fix: Use correct CSP for login page 2025-12-10 21:54:48 +00:00
8991d3935d chore: Ignore formatting PR in blame 2025-12-10 21:54:48 +00:00
b4f9dc35c1 chore: Fix most clippy issue, format & typos 2025-12-10 21:54:48 +00:00
fa9424f8e6 remove stale dependency oxide-auth-axum 2025-12-10 21:54:48 +00:00
0766b628ee feat(oidc_provider) use askama templates
Implements a custom OidcResponse with CSP headers and oxide-auth processing
compatibility.
2025-12-10 21:54:48 +00:00
08f536c335 rebase on current main 2025-12-10 21:54:48 +00:00
eb06fa1a85 impl MSC2966: register clients dynamically 2025-12-10 21:54:48 +00:00
650108ac81 impl MSC2964: OIDC token flow 2025-12-10 21:54:48 +00:00
4fb7cf0eee impl MSC2965: self-advertise as OIDC authentication provider
MSC2965 proposes to let the homeserver advertise its current OIDC authentication
issuer. These changes let conduwuit advertise itself as the issuer when
[global.auth.enable_oidc_login] is set. It also advertises its account management
endpoint if [global.auth.enable_oidc_account_management] is set.

None of these endpoints are implemented. This commit only implements the bare
advertisement, as requested by the MSC.
2025-12-10 21:54:48 +00:00