Skip to content
This repository has been archived by the owner on Sep 10, 2024. It is now read-only.

Commit

Permalink
Implementation of MSC3824 actions for compat (#221)
Browse files Browse the repository at this point in the history
Co-authored-by: Quentin Gliech <quenting@element.io>
  • Loading branch information
hughns and sandhose authored May 31, 2022
1 parent 0a32ba3 commit 35fa7c7
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions crates/handlers/src/compat/login.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,29 @@ use thiserror::Error;

use super::MatrixError;

#[derive(Debug, Serialize)]
#[serde(rename_all = "lowercase")]
enum Action {
Login,
Register,
}

#[derive(Debug, Serialize)]
#[serde(tag = "type")]
enum LoginType {
#[serde(rename = "m.login.password")]
Password,
Password { actions: Vec<Action> },

// we will leave MSC3824 `actions` as undefined for this auth type as unclear
// how it should be interpreted
#[serde(rename = "m.login.token")]
Token,

#[serde(rename = "m.login.sso")]
Sso {
#[serde(skip_serializing_if = "Vec::is_empty")]
identity_providers: Vec<SsoIdentityProvider>,
actions: Vec<Action>,
},
}

Expand All @@ -63,9 +73,12 @@ struct LoginTypes {
pub(crate) async fn get() -> impl IntoResponse {
let res = LoginTypes {
flows: vec![
LoginType::Password,
LoginType::Password {
actions: vec![Action::Login],
},
LoginType::Sso {
identity_providers: vec![],
actions: vec![Action::Login, Action::Register],
},
LoginType::Token,
],
Expand Down

0 comments on commit 35fa7c7

Please sign in to comment.