Skip to content

feat(ffi): Expose legacy SSO support infomation #5222

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
7 changes: 7 additions & 0 deletions bindings/matrix-sdk-ffi/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ All notable changes to this project will be documented in this file.

## [Unreleased] - ReleaseDate

Additions:

- Add `HomeserverLoginDetails::supports_sso_login` for legacy SSO support infomation.
This is primarily for Element X to give a dedicated error message in case
it connects a homeserver with only this method avaliable.
([#5222](https://github.com/matrix-org/matrix-rust-sdk/pull/5222))

## [0.12.0] - 2025-06-10

Breaking changes:
Expand Down
6 changes: 6 additions & 0 deletions bindings/matrix-sdk-ffi/src/authentication.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ pub struct HomeserverLoginDetails {
pub(crate) sliding_sync_version: SlidingSyncVersion,
pub(crate) supports_oidc_login: bool,
pub(crate) supported_oidc_prompts: Vec<OidcPrompt>,
pub(crate) supports_sso_login: bool,
pub(crate) supports_password_login: bool,
}

Expand All @@ -43,6 +44,11 @@ impl HomeserverLoginDetails {
self.supports_oidc_login
}

/// Whether the current homeserver supports login using legacy SSO.
pub fn supports_sso_login(&self) -> bool {
self.supports_sso_login
}

/// The prompts advertised by the authentication issuer for use in the login
/// URL.
pub fn supported_oidc_prompts(&self) -> Vec<OidcPrompt> {
Expand Down
32 changes: 19 additions & 13 deletions bindings/matrix-sdk-ffi/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,14 +335,32 @@ impl Client {
}
};

let supports_password_login = self.supports_password_login().await.ok().unwrap_or(false);
let login_types = self.inner.matrix_auth().get_login_types().await.ok();
let supports_password_login = login_types
.as_ref()
.map(|login_types| {
login_types.flows.iter().any(|login_type| {
matches!(login_type, get_login_types::v3::LoginType::Password(_))
})
})
.unwrap_or(false);
let supports_sso_login = login_types
.as_ref()
.map(|login_types| {
login_types
.flows
.iter()
.any(|login_type| matches!(login_type, get_login_types::v3::LoginType::Sso(_)))
})
.unwrap_or(false);
let sliding_sync_version = self.sliding_sync_version();

Arc::new(HomeserverLoginDetails {
url: self.homeserver(),
sliding_sync_version,
supports_oidc_login,
supported_oidc_prompts,
supports_sso_login,
supports_password_login,
})
}
Expand Down Expand Up @@ -733,18 +751,6 @@ impl Client {
}
}

impl Client {
/// Whether or not the client's homeserver supports the password login flow.
pub(crate) async fn supports_password_login(&self) -> anyhow::Result<bool> {
let login_types = self.inner.matrix_auth().get_login_types().await?;
let supports_password = login_types
.flows
.iter()
.any(|login_type| matches!(login_type, get_login_types::v3::LoginType::Password(_)));
Ok(supports_password)
}
}

#[matrix_sdk_ffi_macros::export]
impl Client {
/// The sliding sync version.
Expand Down