client-api: Add fallbacks for UIAA and login
This commit is contained in:
parent
8a147f08d1
commit
4bfd60ffdd
@ -1,5 +1,6 @@
|
||||
//! Endpoints for user session management.
|
||||
|
||||
pub mod fallback;
|
||||
pub mod get_login_types;
|
||||
pub mod login;
|
||||
pub mod logout;
|
||||
|
53
crates/ruma-client-api/src/r0/session/fallback.rs
Normal file
53
crates/ruma-client-api/src/r0/session/fallback.rs
Normal file
@ -0,0 +1,53 @@
|
||||
//! [GET /_matrix/static/client/login/](https://spec.matrix.org/unstable/client-server-api/#login-fallback)
|
||||
|
||||
use ruma_api::ruma_api;
|
||||
use ruma_identifiers::DeviceId;
|
||||
|
||||
ruma_api! {
|
||||
metadata: {
|
||||
description: "Get login fallback web page.",
|
||||
method: GET,
|
||||
name: "login_fallback",
|
||||
path: "/_matrix/static/client/login/",
|
||||
rate_limited: false,
|
||||
authentication: None,
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
request: {
|
||||
/// ID of the client device.
|
||||
#[ruma_api(query)]
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub device_id: Option<&'a DeviceId>,
|
||||
|
||||
/// A display name to assign to the newly-created device.
|
||||
///
|
||||
/// Ignored if `device_id` corresponds to a known device.
|
||||
#[ruma_api(query)]
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub initial_device_display_name: Option<&'a str>,
|
||||
}
|
||||
|
||||
response: {
|
||||
/// HTML to return to client.
|
||||
#[ruma_api(raw_body)]
|
||||
pub body: Vec<u8>,
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
/// Creates a new `Request` with the given auth type and session ID.
|
||||
pub fn new(
|
||||
device_id: Option<&'a DeviceId>,
|
||||
initial_device_display_name: Option<&'a str>,
|
||||
) -> Self {
|
||||
Self { device_id, initial_device_display_name }
|
||||
}
|
||||
}
|
||||
|
||||
impl Response {
|
||||
/// Creates a new `Response` with the given HTML body.
|
||||
pub fn new(body: Vec<u8>) -> Self {
|
||||
Self { body }
|
||||
}
|
||||
}
|
@ -17,6 +17,8 @@ use serde_json::{
|
||||
|
||||
use crate::error::{Error as MatrixError, ErrorBody};
|
||||
|
||||
pub mod fallback;
|
||||
|
||||
/// Additional authentication information for the user-interactive authentication API.
|
||||
#[derive(Clone, Debug, Outgoing, Serialize)]
|
||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||
|
51
crates/ruma-client-api/src/r0/uiaa/fallback.rs
Normal file
51
crates/ruma-client-api/src/r0/uiaa/fallback.rs
Normal file
@ -0,0 +1,51 @@
|
||||
//! [GET /_matrix/client/r0/auth/{auth_type}/fallback/web?session={session_id}](https://matrix.org/docs/spec/client_server/r0.6.1#fallback)
|
||||
|
||||
use ruma_api::ruma_api;
|
||||
|
||||
ruma_api! {
|
||||
metadata: {
|
||||
description: "Get UIAA fallback web page.",
|
||||
method: GET,
|
||||
name: "uiaa_fallback",
|
||||
path: "/_matrix/client/r0/auth/:auth_type/fallback/web",
|
||||
rate_limited: false,
|
||||
authentication: None,
|
||||
}
|
||||
|
||||
request: {
|
||||
/// The type name ("m.login.dummy", etc.) of the uiaa stage to get a fallback page for.
|
||||
#[ruma_api(path)]
|
||||
pub auth_type: String,
|
||||
|
||||
/// The ID of the session given by the homeserver.
|
||||
#[ruma_api(query)]
|
||||
pub session: String,
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
response: {
|
||||
/// Optional URI to redirect to.
|
||||
#[ruma_api(header = LOCATION)]
|
||||
pub redirect_url: Option<String>,
|
||||
|
||||
/// HTML to return to client.
|
||||
#[ruma_api(raw_body)]
|
||||
pub body: Vec<u8>,
|
||||
}
|
||||
|
||||
error: crate::Error
|
||||
}
|
||||
|
||||
impl Request {
|
||||
/// Creates a new `Request` with the given auth type and session ID.
|
||||
pub fn new(auth_type: String, session: String) -> Self {
|
||||
Self { auth_type, session }
|
||||
}
|
||||
}
|
||||
|
||||
impl Response {
|
||||
/// Creates a new `Response` with the given redirect URL and HTML body.
|
||||
pub fn new(redirect_url: Option<String>, body: Vec<u8>) -> Self {
|
||||
Self { redirect_url, body }
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user