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

Implementation of MSC3824 actions for compat #221

Merged
merged 5 commits into from
May 31, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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