-
Notifications
You must be signed in to change notification settings - Fork 41
Closed
Milestone
Description
This depends on issue #113 and is a follow-up to that issue, which only describes setting up a basic login screen that supports username+password only.
Once a basic username+password login screen is working, we should add SSO login support such that users can login via third-party auth providers like a Google account, Facebook, GitHub, Twitter, Apple, etc.
Fortunately, the Matrix SDK provides many authentication APIs as part of the MatrixAuth type. You can access this type via the client.matrix_auth() function.
Here is the current login flow in the sliding_sync.rs file:
Lines 79 to 106 in 106033d
| // Query the server for supported login types. | |
| let login_kinds = client.matrix_auth().get_login_types().await?; | |
| if !login_kinds.flows.iter().any(|flow| matches!(flow, LoginType::Password(_))) { | |
| bail!("Server does not support username + password login flow."); | |
| } | |
| // Attempt to login using the CLI-provided username & password. | |
| let login_result = client | |
| .matrix_auth() | |
| .login_username(&cli.username, &cli.password) | |
| .initial_device_display_name("robrix-un-pw") | |
| .send() | |
| .await?; | |
| log!("Login result: {login_result:?}"); | |
| if client.logged_in() { | |
| log!("Logged in successfully? {:?}", client.logged_in()); | |
| enqueue_rooms_list_update(RoomsListUpdate::Status { | |
| status: format!("Logged in as {}. Loading rooms...", &cli.username), | |
| }); | |
| Ok((client, _token)) | |
| } else { | |
| enqueue_rooms_list_update(RoomsListUpdate::Status { | |
| status: format!("Failed to login as {}: {:?}", &cli.username, login_result), | |
| }); | |
| bail!("Failed to login as {}: {login_result:?}", &cli.username) | |
| } |
Note that the first step is querying which login types are supported by the server, which you can then iterate over and inspect using the
LoginType enum.Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Status
Done