matrix-org / matrix-org/matrix-rust-sdk

Migrate the session to use MAS if the homeserver has been migrated.

Open
#4,949 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
2.3k
Forks
500
Avg merge
1d 16h
Merged PRs (30d)
106

Description

Following the migration of matrix.org to use MAS it has become apparent that the SDK also needs to do some work to migrate the Session too. A visible result of this is that in Element X, only new logins against matrix.org show the Manage Account/Manage Devices buttons in settings. Following this through in the code:

When creating a Session the existing auth_api is used to set some oidc_data that is stored:

https://github.com/matrix-org/matrix-rust-sdk/blob/0306683cbf7f2d12f4c298e19ba38d3898fbd8d4/bindings/matrix-sdk-ffi/src/client.rs#L1620-L1659

Then when restoring that Session the presence of some oidc_data determines which auth_api is used in the new Client instance.

https://github.com/matrix-org/matrix-rust-sdk/blob/0306683cbf7f2d12f4c298e19ba38d3898fbd8d4/bindings/matrix-sdk-ffi/src/client.rs#L1680-L1706

This means that when checking for the account_url, the wrong auth type is present and so no requests can be made to fetch it:

https://github.com/matrix-org/matrix-rust-sdk/blob/bc50cae35fd32b902eac4d86d61ebe2ee7e11df2/bindings/matrix-sdk-ffi/src/client.rs#L617-L619

Furthermore, the API is used in a few places to determine whether requests are sent to the homeserver or the authentication server. For example, the logout function will still send the request to the homeserver when it should be sending this to the authentication server:

https://github.com/matrix-org/matrix-rust-sdk/blob/bad1c683f80cf84d4fc9fb401e8b9fc2a20475ed/crates/matrix-sdk/src/client/mod.rs#L1334-L1340

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in bindings/matrix-sdk-ffi/src/client.rs at the Session creation and restoration paths around lines 1620-1659 and 1680-1706, then inspect the account_url check around lines 617-619. Trace how the restored auth_api is selected and compare it with crates/matrix-sdk/src/client/mod.rs around lines 1334-1340. Done means migrated sessions use the appropriate authentication server for account URL lookup and logout.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
authentication
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.