Commit Graph

221 Commits

Author SHA1 Message Date
Jonas Platte
3aa356dcd6 chore: Use shorter syntax for workspace inheritance where possible 2025-05-23 10:23:36 +02:00
Jonas Platte
491f7cd529 chore: Clean up Cargo.toml formatting 2025-05-23 10:23:36 +02:00
Jonas Platte
e3bcd4d5b2 chore: Upgrade dirs to 6.0 in examples 2025-05-19 09:23:02 +02:00
Kévin Commaille
43431b88da feat(sdk): Add Client::logout() to log out regardless of the auth API
It simplifies code for users, and avoids to have to match on
`AuthApi`, which is a non-exhaustive enum.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-04-04 13:14:55 +02:00
Kévin Commaille
c8da9cb462 refactor(oauth): Remove the issuer from OAuthAuthData
It is actually unused, and now that we only need homeserver URLs for
static registrations, users don't need to access it easily.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-04-03 12:52:17 +03:00
Kévin Commaille
8883e081af refactor(oauth): Remove OAuthRegistrationStore
MSC2966 was updated, clients should re-register for every log in, so we
don't need to store the client IDs between logins.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-04-03 12:52:17 +03:00
Kévin Commaille
e0e9c06ca4 Don't use serde to avoid returning an error
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-26 15:26:55 +01:00
Kévin Commaille
bc22ff1221 refactor(oauth): Introduce AccountManagementUrlBuilder
It allows to reuse the URL for different actions more easily than having
to call `OAuth::account_management_url` every time for a different
action.

It also adds a method with fallback if we want to ignore action
serialization errors, to always present a URL.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-26 15:26:55 +01:00
Kévin Commaille
f6c5addf55 refactor(sdk): Remove experimental-oidc feature
Now that is compiles under WASM and that the API was cleaned up, it
should be okay.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-24 14:04:04 +02:00
Kévin Commaille
dcd0e078f6 docs(qr-login): Update docs
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-24 09:32:05 +00:00
Kévin Commaille
78b79a758f feat(oauth-cli): Use OAuthRegistrationStore
It's probably the recommended way to do registration when the client can create files.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-24 09:32:05 +00:00
Kévin Commaille
29f6606d99 refactor(examples): Rename oidc_cli to oauth_cli
And update the docs.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-24 09:32:05 +00:00
Kévin Commaille
b3e82a05db refactor(oauth): Merge OAuth::login_with_oidc_callback() and OAuth::finish_login()
Accept a URL or a query string for simplicity.

That way we don't need to expose AuthorizationResponse.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-21 19:17:13 +01:00
Kévin Commaille
a8aa364757 refactor(oauth): Allow to use any registration method with OAuth::login
Gets rid of OAuth::url_for_oidc since it can be replaced by a call to
OAuth::login now.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-21 19:17:13 +01:00
Kévin Commaille
7457ecb1a8 feat(oauth): Allow to use any registration method with login_with_qr_code
Introduces the ClientRegistrationMethod type

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-21 19:17:13 +01:00
Kévin Commaille
b408087320 refactor(oauth): OAuth::login doesn't return a Result
There is actually no way to get an error.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-21 19:17:13 +01:00
Kévin Commaille
8683ca4d13 refactor(oauth): Re-export ClientID from the oauth module
Since it is now used everywhere, there is no reason to reexport it from
the registrations module.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-21 10:49:46 +01:00
Kévin Commaille
45dd96e30a refactor(oauth): Merge finish_authorization and finish_login
That way users only need to call finish_login, since there is no other
reason to call finish_authorization currently.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-20 16:02:18 +00:00
Kévin Commaille
b9c970dc43 refactor(oauth): Rename OauthGrantType to OAuthGrantType
For consistency.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-18 17:18:34 +01:00
Kévin Commaille
c0d3ed1a90 refactor(oauth): Rename provider_metadata to server_metadata
"Provider" is an OpenID Connect term. OAuth 2.0 uses the "authorization
server" term.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-18 17:18:34 +01:00
Kévin Commaille
00d7a77ebe refactor(encryption): Rename OidcCrossSigningResetInfo to OAuthCrossSigningResetInfo
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-18 17:18:34 +01:00
Kévin Commaille
f29d3fd666 refactor(oauth): Rename OidcAuthCodeUrlBuilder to OAuthAuthCodeUrlBuilder
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-18 17:18:34 +01:00
Kévin Commaille
f4bb14a30e refactor(oauth): Rename OidcSession to OAuthSession
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-18 17:18:34 +01:00
Kévin Commaille
6f3694cfa9 refactor(oauth): Rename Oidc API to OAuth
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-18 17:18:34 +01:00
Kévin Commaille
1658610f93 refactor(sdk): Rename oidc module to oauth
Since we mostly use OAuth 2.0 now.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-18 17:18:34 +01:00
Kévin Commaille
f8abb85e9e refactor(oidc_cli): Use LocalServerBuilder
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-18 09:55:01 +01:00
Kévin Commaille
7713ce768a refactor(oidc): Create ClientMetadata type
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-14 18:03:34 +01:00
Kévin Commaille
aea573d001 refactor(oidc): Import code to register a client
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-14 18:03:34 +01:00
Kévin Commaille
7ca6494efa refactor(oidc): Remove support for software statement
It is not mentionned in MSC2966
2025-03-14 18:03:34 +01:00
Kévin Commaille
2c6c818005 refactor(oidc): Use ruma's server metadata type
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-14 18:03:34 +01:00
Kévin Commaille
9adff21f78 refactor(oidc): Import code for building the account management URL
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-14 18:03:34 +01:00
Kévin Commaille
dd01479c6b refactor(sdk): Use a single SessionTokens type
Since MatrixSessionTokens and OidcSessionTokens are identical.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-10 09:12:38 +01:00
Kévin Commaille
e15897b3f1 refactor(oidc): Use oauth2 for authorization code grant
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-06 12:27:30 +01:00
Kévin Commaille
0967027feb refactor(oidc): Use ClientId type from oauth2
Avoids to use 2 similar types with the same name.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-06 12:27:30 +01:00
Kévin Commaille
81dbe2060c refactor(oidc): Remove support for ID tokens
ID tokens are a feature of OpenID Connect, we don't need them to support OAuth 2.0.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-05 14:19:27 +01:00
Kévin Commaille
d4b92de8e4 refactor(oidc): Remove support for OIDC RP-Initiated logout
Token revocation was split out from MSC2964 to MSC4254, and RP-Initiated
logout is now mentioned only as an alternative.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-02-24 14:19:48 +01:00
Kévin Commaille
0a4db305b9 refactor(oidc): Move qrcode module inside oidc
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-02-24 13:39:23 +01:00
Kévin Commaille
2eb2ae7959 refactor(oidc): Use the GET /auth_metadata Matrix endpoint (#4673)
This is the method to get the server metadata in the latest draft of
[MSC2965](https://github.com/matrix-org/matrix-spec-proposals/pull/2965).

We still keep the old behavior with `GET /auth_issuer` as fallback for
now because it has wider server support.

There are some pre-main commit cleanups to simplify the main commit.
This can be reviewed commit by commit.

The changes were tested with the oidc_cli example on beta.matrix.org.

Closes #4550.

---------

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-02-18 17:41:48 +01:00
Kévin Commaille
1c114978e4 refactor(oidc): Remove method to authorize arbitrary scope
Only the scopes necessary during login are specified in MSC2967 now.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-02-17 12:02:43 +01:00
Damir Jelić
aa9aef44f7 refactor: Rename Oidc::account_management_url to fetch_account_management_url 2025-02-13 12:32:42 +01:00
Kévin Commaille
31e78c2a1b refactor(oidc): Only support public clients (#4634)
This should be the most common case, and is already the only case
supported by the higher level APIs like `url_for_oidc` and
`login_with_qr_code`. It simplifies the API because we can call
`restore_registered_client` directly from `register_client`, which was a
TODO.

- [x] Public API changes documented in changelogs (optional)

---------

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-02-13 11:40:17 +01:00
Damir Jelić
252786d2ef refactor(ui): Make SyncService::stop infallible
The `SyncService::stop()` method could fail for the following reasons:

1. The supervisor was not properly started up, this is a programmer error.
2. The supervisor task wouldn't shut down and instead it returns a JoinError.
3. We couldn't notify the supervisor task that it should shutdown due the channel being closed.

All of those cases shouldn't ever happen and the supervisor task will be
stopped in all of them.

1. Since there is no supervisor to be stopped, we can safely just log an
   error, our tests ensure that a `SyncService::start()` does create a
   supervisor.

2. A JoinError can be returned if the task has been cancelled or if the
   supervisor task has panicked. Since we never cancel the task, nor
   have any panics in the supervisor task, we can assume that this won't
   happen.

3. The supervisor task holds on to a reference to the receiving end of
   the channel, as long as the task is alive the channel can not be
   closed.

In conclusion, it doesn't seem to be useful to forward these error cases
to the user.
2025-01-31 09:58:55 +01:00
Damir Jelić
9d732395ce feat(ui): Introduce a "offline" mode for the SyncService 2025-01-31 09:58:55 +01:00
Ivan Enderlin
5b3b87d3e2 chore(ui): Rename Timeline::subscribe_batched to ::subscribe.
This patch renames `Timeline::subscribe_batched` to
`Timeline::subscribe`. Since the `Timeline::subscribe` method has been
removed because unused, it no longer makes sense to have a “batched”
variant here. Let's simplify things!
2025-01-28 09:54:31 +01:00
Kévin Commaille
3e78e441d4 refactor(sdk): Move oidc module to authentication::oidc
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-01-22 20:22:13 +01:00
Kévin Commaille
02c2e55855 refactor(sdk): Move matrix_auth module to authentication::matrix
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-01-22 20:22:13 +01:00
Ivan Enderlin
4684cfb780 chore: Replace Timeline::subscribe by Timeline::subscribe_batched.
This patch changes all calls to `Timeline::subscribe` to replace them by
`Timeline::subscribe_batched`. Most of them are in tests. It's the first
step of a plan to remove `Timeline::subscribe`.

The rest of the patch updates all the tests to use
`Timeline::subscribe_batched`.
2025-01-22 11:55:23 +01:00
Jonas Platte
6c053a86bf chore: Fix new nightly warnings 2025-01-09 16:20:51 -05:00
Benjamin Bouvier
618e47250d feat!(base): reintroduce Room::display_name
`compute_display_name` is made private again, and used only within the
base crate. A new public counterpart `Room::display_name` is introduced,
which returns a cached value for, or computes (and fills in cache) the
display name. This is simpler to use, and likely what most users expect
anyways.
2025-01-07 15:25:32 +01:00
Benjamin Bouvier
5f5e979e16 refactor!: Put the RequestConfig argument of Client::send() into a builder method
Instead of `Client::send(request, request_config)`, consumers can now do
`Client::send(request).with_request_config(request_config)`.
2024-12-20 10:35:18 +01:00