Commit Graph

239 Commits

Author SHA1 Message Date
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
Kévin Commaille
8d2e672996 feat!: Upgrade Ruma to 0.12.0
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2024-12-16 11:56:44 +01:00
Damir Jelić
dcf6af405d chore: Silence unexpected cfg warnings
These are all coming from macro invocations of macros that are defined
in other crates. It's likely a clippy issue. We should try to revert
this the next time we bump the nightly version we're using.
2024-11-27 13:23:34 +01:00
Damir Jelić
ace96e372f chore: Fix a warning from an invalid Cargo.toml config for the OIDC example 2024-11-05 16:30:25 +01:00
Damir Jelić
ca7f2ad3d0 Add a cargo-release config 2024-10-10 14:32:46 +02:00
Benjamin Bouvier
cb51a3155a chore: get rid of unused dependencies 2024-10-10 14:18:36 +02:00
Damir Jelić
657c72904a chore: Define our license in every crate we have 2024-10-04 16:53:17 +02:00
Damir Jelić
de752eb089 chore: Use a released version of the qrcode crate for the qr-login example 2024-10-04 16:53:17 +02:00
Kévin Commaille
65b422312c chore: Enable the proper feature of tower
We only use `service_fn` which is behind the `util` feature.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2024-10-04 12:51:38 +02:00
Benjamin Bouvier
06e9f01a4a chore: fix new typos 2024-10-01 14:07:14 +02:00
Damir Jelić
4fdc78f565 doc: Shorten one of our doc examples 2024-07-26 13:29:37 +02:00
Damir Jelić
d9e91344aa examples: Update the cross-signing bootstrap example to use the new method 2024-07-24 11:03:54 +02:00
Damir Jelić
4883f3fa77 examples: Add a reset-cross-signing command to the oidc example 2024-07-24 11:03:54 +02:00
Ivan Enderlin
bacf85d807 chore: Use anyhow from the workspace. 2024-07-11 11:16:17 +02:00
Ivan Enderlin
b163368be0 chore: Use futures-util from the workspace. 2024-07-11 11:16:17 +02:00
Ivan Enderlin
5ebfd7bc55 chore: Use tokio from the workspace. 2024-07-11 11:16:17 +02:00
Ivan Enderlin
0d264d209f chore: Use tracing-subscriber from the workspace. 2024-07-11 11:16:17 +02:00
Damir Jelić
6dde95c865 examples: Add a recovery command to the oidc-cli example
This adds support to input your recovery key to the OIDC example which
will allow the OIDC example client to be verified and have access to all
the secrets (cross-signing keys and the backup recovery key).

Not particularly useful right now, but once the OIDC example is able to
log in other devices via a QR code it becomes necessary to have access
to all the secrets.
2024-06-20 13:43:14 +02:00
Damir Jelić
9b05d0d822 crypto: Use the server name in the QR code login data (#3537)
Using the resolved homeserver URL causes problems if we need to inspect
the well-known configuration of the homeserver, for example, if the
server name is matrix.org, but the homeserver URL is server.matrix.org,
the well-known might be only available for the former.

This is why we also need to receive the former, i.e. the server name in
the QR code data.
2024-06-13 14:16:48 +02:00
Benjamin Bouvier
e22162a23a base: rename computed_display_name to compute_display_name and remove computed_ in the cached one 2024-06-11 15:44:53 +02:00
Benjamin Bouvier
6012c7d98b chore: remove unused dependencies
Thanks cargo-machete.
2024-05-31 17:26:57 +02:00
Kévin Commaille
0db486b511 crypto: Add SasState::Created variant
To differentiate the SAS state between the party
that sent the verification start and the party that received it.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2024-05-30 12:09:46 +02:00
Damir Jelić
7dd08c3b81 Add an example for the QR code login 2024-05-28 12:43:49 +02:00
Damir Jelić
6672302684 chore: Make the url crate a workspace dependency 2024-05-14 10:47:22 +02:00
Damir Jelić
6f2d8e0e50 chore: Fix some clippy warnings 2024-05-02 17:12:19 +02:00
Benjamin Bouvier
90bed18415 ffi: make the name method sync again
Also:

- rename `display_name` to `computed_display_name` in several places,
and reflect that change into a few callers
- simplify slightly the `computed_display_name()` method
2024-05-01 14:32:38 +02:00
Damir Jelić
fb9982fb48 oidc: Use the correct types to compare the status codes in the oidc example (#3363) 2024-04-30 13:02:29 +00:00
Kévin Commaille
ea1a01000f sdk: Use the GET /auth_issuer endpoint for OIDC
The well-known method is deprecated.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2024-04-30 12:33:31 +02:00
Kévin Commaille
0e0a406cb1 Replace hyper with axum for oidc_cli example
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2024-04-27 19:37:46 +02:00
Kévin Commaille
da2abccc0d chore: Disable clippy::assigning_clones lint
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2024-04-02 15:05:41 +02:00
Kévin Commaille
f9ab073adf chore: Avoid redundant imports
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2024-04-02 13:27:58 +02:00
Marco Antonio Alvarez
10069fbead MSC2530: added the ability to send media with captions (#3226)
Now that there is some support for [MSC2530](https://github.com/matrix-org/matrix-spec-proposals/pull/2530), I gave adding sending captions a try. ( This is my first time with Rust 😄  )

I tried it on Element X with a hardcoded caption and it seems to work well
![image](https://github.com/matrix-org/matrix-rust-sdk/assets/683652/597e5ebf-f7f2-498f-97a4-ac98613c1134)

(It even got forwarded through mautrix-whatsapp and the caption was visible on the Whatsapp side)

---

* ffi: Expose filename and formatted body fields for media captions

In relevance to MSC2530

* MSC2530: added the ability to send media with captions

Signed-off-by: Marco Antonio Alvarez <surakin@gmail.com>

* signoff

Signed-off-by: Marco Antonio Alvarez <surakin@gmail.com>

* fixing the import messup

* fix missing parameters in documentation

* fix formatting

* move optional parameters to the end

* more formatting fixes

* more formatting fixes

* rename url parameter to filename in send_attachment and helpers

* fix send_attachment documentation example

* move caption and formatted_caption into attachmentconfig

* fix formatting

* fix formatting

* fix formatting (hopefully the last one)

* updated stale comments

* simplify attachment message comments

---------

Signed-off-by: Marco Antonio Alvarez <surakin@gmail.com>
Co-authored-by: SpiritCroc <dev@spiritcroc.de>
2024-03-19 11:08:47 +01:00
Johannes Marbach
b68bcf9cff fix(examples): Fix typos in getting started example
Signed-off-by: Johannes Marbach <n0-0ne+github@mailbox.org>
2024-02-25 11:35:59 +01:00