client-api: Move MSC2858 out of unstable-pre-spec
This commit is contained in:
parent
e4a21580a2
commit
b8a741cb30
@ -3,6 +3,7 @@
|
|||||||
Bug fixes:
|
Bug fixes:
|
||||||
|
|
||||||
* Fix deserialization of `r0::session::get_login_types::CustomLoginType`.
|
* Fix deserialization of `r0::session::get_login_types::CustomLoginType`.
|
||||||
|
* Make fields of `r0::session::get_login_types::IdentityProvider` public.
|
||||||
|
|
||||||
Breaking changes:
|
Breaking changes:
|
||||||
|
|
||||||
@ -38,6 +39,10 @@ Improvements:
|
|||||||
`IncomingAuthData::to_outgoing` on it.
|
`IncomingAuthData::to_outgoing` on it.
|
||||||
* Add custom variant to `LoginInfo` which can be constructed with `IncomingLoginInfo::new` and
|
* Add custom variant to `LoginInfo` which can be constructed with `IncomingLoginInfo::new` and
|
||||||
then call `IncomingLoginInfo::to_outgoing` on it.
|
then call `IncomingLoginInfo::to_outgoing` on it.
|
||||||
|
* Move MSC2858 - Multiple SSO Identity Providers out of the `unstable-pre-spec` feature flag, this
|
||||||
|
includes:
|
||||||
|
* The `r0::session::get_login_types::{IdentityProvider, IdentityProviderBrand}` types
|
||||||
|
* The `session::sso_login_with_provider::v3` endpoint
|
||||||
|
|
||||||
# 0.12.3
|
# 0.12.3
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
pub mod error;
|
pub mod error;
|
||||||
pub mod r0;
|
pub mod r0;
|
||||||
|
pub mod session;
|
||||||
pub mod unversioned;
|
pub mod unversioned;
|
||||||
|
|
||||||
pub use error::Error;
|
pub use error::Error;
|
||||||
|
@ -6,5 +6,3 @@ pub mod login_fallback;
|
|||||||
pub mod logout;
|
pub mod logout;
|
||||||
pub mod logout_all;
|
pub mod logout_all;
|
||||||
pub mod sso_login;
|
pub mod sso_login;
|
||||||
#[cfg(feature = "unstable-pre-spec")]
|
|
||||||
pub mod sso_login_with_provider;
|
|
||||||
|
@ -3,15 +3,11 @@
|
|||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
|
|
||||||
use ruma_api::ruma_api;
|
use ruma_api::ruma_api;
|
||||||
#[cfg(feature = "unstable-pre-spec")]
|
|
||||||
use ruma_identifiers::MxcUri;
|
use ruma_identifiers::MxcUri;
|
||||||
use ruma_serde::JsonObject;
|
use ruma_serde::{JsonObject, StringEnum};
|
||||||
#[cfg(feature = "unstable-pre-spec")]
|
|
||||||
use ruma_serde::StringEnum;
|
|
||||||
use serde::{de::DeserializeOwned, Deserialize, Serialize};
|
use serde::{de::DeserializeOwned, Deserialize, Serialize};
|
||||||
use serde_json::Value as JsonValue;
|
use serde_json::Value as JsonValue;
|
||||||
|
|
||||||
#[cfg(feature = "unstable-pre-spec")]
|
|
||||||
use crate::PrivOwnedStr;
|
use crate::PrivOwnedStr;
|
||||||
|
|
||||||
ruma_api! {
|
ruma_api! {
|
||||||
@ -150,15 +146,7 @@ impl TokenLoginType {
|
|||||||
#[serde(tag = "type", rename = "m.login.sso")]
|
#[serde(tag = "type", rename = "m.login.sso")]
|
||||||
pub struct SsoLoginType {
|
pub struct SsoLoginType {
|
||||||
/// The identity provider choices.
|
/// The identity provider choices.
|
||||||
///
|
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||||
/// This uses the unstable prefix in
|
|
||||||
/// [MSC2858](https://github.com/matrix-org/matrix-doc/pull/2858).
|
|
||||||
#[cfg(feature = "unstable-pre-spec")]
|
|
||||||
#[serde(
|
|
||||||
default,
|
|
||||||
rename = "org.matrix.msc2858.identity_providers",
|
|
||||||
skip_serializing_if = "Vec::is_empty"
|
|
||||||
)]
|
|
||||||
pub identity_providers: Vec<IdentityProvider>,
|
pub identity_providers: Vec<IdentityProvider>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -170,24 +158,22 @@ impl SsoLoginType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// An SSO login identity provider.
|
/// An SSO login identity provider.
|
||||||
#[cfg(feature = "unstable-pre-spec")]
|
|
||||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||||
pub struct IdentityProvider {
|
pub struct IdentityProvider {
|
||||||
/// The ID of the provider.
|
/// The ID of the provider.
|
||||||
id: String,
|
pub id: String,
|
||||||
|
|
||||||
/// The display name of the provider.
|
/// The display name of the provider.
|
||||||
name: String,
|
pub name: String,
|
||||||
|
|
||||||
/// The icon for the provider.
|
/// The icon for the provider.
|
||||||
icon: Option<Box<MxcUri>>,
|
pub icon: Option<Box<MxcUri>>,
|
||||||
|
|
||||||
/// The brand identifier for the provider.
|
/// The brand identifier for the provider.
|
||||||
brand: Option<IdentityProviderBrand>,
|
pub brand: Option<IdentityProviderBrand>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "unstable-pre-spec")]
|
|
||||||
impl IdentityProvider {
|
impl IdentityProvider {
|
||||||
/// Creates an `IdentityProvider` with the given `id` and `name`.
|
/// Creates an `IdentityProvider` with the given `id` and `name`.
|
||||||
pub fn new(id: String, name: String) -> Self {
|
pub fn new(id: String, name: String) -> Self {
|
||||||
@ -196,10 +182,6 @@ impl IdentityProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// An SSO login identity provider brand identifier.
|
/// An SSO login identity provider brand identifier.
|
||||||
///
|
|
||||||
/// This uses the unstable prefix in
|
|
||||||
/// [MSC2858](https://github.com/matrix-org/matrix-doc/pull/2858).
|
|
||||||
#[cfg(feature = "unstable-pre-spec")]
|
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, StringEnum)]
|
#[derive(Clone, Debug, PartialEq, Eq, StringEnum)]
|
||||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||||
pub enum IdentityProviderBrand {
|
pub enum IdentityProviderBrand {
|
||||||
@ -259,13 +241,12 @@ mod login_type_serde;
|
|||||||
mod tests {
|
mod tests {
|
||||||
use matches::assert_matches;
|
use matches::assert_matches;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
#[cfg(feature = "unstable-pre-spec")]
|
use serde_json::{from_value as from_json_value, json, to_value as to_json_value};
|
||||||
use serde_json::to_value as to_json_value;
|
|
||||||
use serde_json::{from_value as from_json_value, json};
|
|
||||||
|
|
||||||
use super::{CustomLoginType, LoginType, PasswordLoginType};
|
use super::{
|
||||||
#[cfg(feature = "unstable-pre-spec")]
|
CustomLoginType, IdentityProvider, IdentityProviderBrand, LoginType, PasswordLoginType,
|
||||||
use super::{IdentityProvider, IdentityProviderBrand, SsoLoginType, TokenLoginType};
|
SsoLoginType, TokenLoginType,
|
||||||
|
};
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
struct Wrapper {
|
struct Wrapper {
|
||||||
@ -309,13 +290,12 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(feature = "unstable-pre-spec")]
|
|
||||||
fn deserialize_sso_login_type() {
|
fn deserialize_sso_login_type() {
|
||||||
let mut wrapper = from_json_value::<Wrapper>(json!({
|
let mut wrapper = from_json_value::<Wrapper>(json!({
|
||||||
"flows": [
|
"flows": [
|
||||||
{
|
{
|
||||||
"type": "m.login.sso",
|
"type": "m.login.sso",
|
||||||
"org.matrix.msc2858.identity_providers": [
|
"identity_providers": [
|
||||||
{
|
{
|
||||||
"id": "oidc-gitlab",
|
"id": "oidc-gitlab",
|
||||||
"name": "GitLab",
|
"name": "GitLab",
|
||||||
@ -367,7 +347,6 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(feature = "unstable-pre-spec")]
|
|
||||||
fn serialize_sso_login_type() {
|
fn serialize_sso_login_type() {
|
||||||
let wrapper = to_json_value(Wrapper {
|
let wrapper = to_json_value(Wrapper {
|
||||||
flows: vec
|
//! [GET /_matrix/client/v3/login/sso/redirect/{idp_id}](https://spec.matrix.org/v1.1/client-server-api/#get_matrixclientv3loginssoredirectidpid)
|
||||||
//!
|
|
||||||
//! This uses the unstable prefix in [MSC2858](https://github.com/matrix-org/matrix-doc/pull/2858).
|
|
||||||
|
|
||||||
use ruma_api::ruma_api;
|
use ruma_api::ruma_api;
|
||||||
|
|
||||||
@ -9,7 +7,7 @@ ruma_api! {
|
|||||||
description: "Get the SSO login identity provider url.",
|
description: "Get the SSO login identity provider url.",
|
||||||
method: GET,
|
method: GET,
|
||||||
name: "sso_login_with_provider",
|
name: "sso_login_with_provider",
|
||||||
path: "/_matrix/client/unstable/org.matrix.msc2858/login/sso/redirect/:idp_id",
|
path: "/_matrix/client/v3/login/sso/redirect/:idp_id",
|
||||||
rate_limited: false,
|
rate_limited: false,
|
||||||
authentication: None,
|
authentication: None,
|
||||||
}
|
}
|
||||||
@ -63,7 +61,7 @@ mod tests {
|
|||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
req.uri().to_string(),
|
req.uri().to_string(),
|
||||||
"https://homeserver.tld/_matrix/client/unstable/org.matrix.msc2858/login/sso/redirect/provider?redirectUrl=https%3A%2F%2Fexample.com%2Fsso"
|
"https://homeserver.tld/_matrix/client/v3/login/sso/redirect/provider?redirectUrl=https%3A%2F%2Fexample.com%2Fsso"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user