Skip to content

Commit 94cc313

Browse files
committed
feat(ffi): Expose legacy SSO support infomation
Currently Element X can't distinguish the cases where a homeserver only supports legacy SSO without OIDC (and password login isn't avaliable), and other server unreachable scenarios. This patch exposes legacy SSO support infomation so that Element X side can give a dedicated error message when it encounters a homeserver that can only support legacy SSO. Signed-off-by: Yorusaka Miyabi <23130178+ShadowRZ@users.noreply.github.com>
1 parent c340a71 commit 94cc313

File tree

3 files changed

+32
-13
lines changed

3 files changed

+32
-13
lines changed

bindings/matrix-sdk-ffi/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ All notable changes to this project will be documented in this file.
66

77
## [Unreleased] - ReleaseDate
88

9+
Additions:
10+
11+
- Add `HomeserverLoginDetails::supports_sso_login` for legacy SSO support infomation.
12+
This is primarily for Element X to give a dedicated error message in case
13+
it connects a homeserver with only this method avaliable.
14+
([#5222](https://github.com/matrix-org/matrix-rust-sdk/pull/5222))
15+
916
## [0.12.0] - 2025-06-10
1017

1118
Breaking changes:

bindings/matrix-sdk-ffi/src/authentication.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ pub struct HomeserverLoginDetails {
2323
pub(crate) sliding_sync_version: SlidingSyncVersion,
2424
pub(crate) supports_oidc_login: bool,
2525
pub(crate) supported_oidc_prompts: Vec<OidcPrompt>,
26+
pub(crate) supports_sso_login: bool,
2627
pub(crate) supports_password_login: bool,
2728
}
2829

@@ -43,6 +44,11 @@ impl HomeserverLoginDetails {
4344
self.supports_oidc_login
4445
}
4546

47+
/// Whether the current homeserver supports login using legacy SSO.
48+
pub fn supports_sso_login(&self) -> bool {
49+
self.supports_sso_login
50+
}
51+
4652
/// The prompts advertised by the authentication issuer for use in the login
4753
/// URL.
4854
pub fn supported_oidc_prompts(&self) -> Vec<OidcPrompt> {

bindings/matrix-sdk-ffi/src/client.rs

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -335,14 +335,32 @@ impl Client {
335335
}
336336
};
337337

338-
let supports_password_login = self.supports_password_login().await.ok().unwrap_or(false);
338+
let login_types = self.inner.matrix_auth().get_login_types().await.ok();
339+
let supports_password_login = login_types
340+
.as_ref()
341+
.map(|login_types| {
342+
login_types.flows.iter().any(|login_type| {
343+
matches!(login_type, get_login_types::v3::LoginType::Password(_))
344+
})
345+
})
346+
.unwrap_or(false);
347+
let supports_sso_login = login_types
348+
.as_ref()
349+
.map(|login_types| {
350+
login_types
351+
.flows
352+
.iter()
353+
.any(|login_type| matches!(login_type, get_login_types::v3::LoginType::Sso(_)))
354+
})
355+
.unwrap_or(false);
339356
let sliding_sync_version = self.sliding_sync_version();
340357

341358
Arc::new(HomeserverLoginDetails {
342359
url: self.homeserver(),
343360
sliding_sync_version,
344361
supports_oidc_login,
345362
supported_oidc_prompts,
363+
supports_sso_login,
346364
supports_password_login,
347365
})
348366
}
@@ -733,18 +751,6 @@ impl Client {
733751
}
734752
}
735753

736-
impl Client {
737-
/// Whether or not the client's homeserver supports the password login flow.
738-
pub(crate) async fn supports_password_login(&self) -> anyhow::Result<bool> {
739-
let login_types = self.inner.matrix_auth().get_login_types().await?;
740-
let supports_password = login_types
741-
.flows
742-
.iter()
743-
.any(|login_type| matches!(login_type, get_login_types::v3::LoginType::Password(_)));
744-
Ok(supports_password)
745-
}
746-
}
747-
748754
#[matrix_sdk_ffi_macros::export]
749755
impl Client {
750756
/// The sliding sync version.

0 commit comments

Comments
 (0)