Skip to content

Commit d82d0f6

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 d82d0f6

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ pub struct HomeserverLoginDetails {
2222
pub(crate) url: String,
2323
pub(crate) sliding_sync_version: SlidingSyncVersion,
2424
pub(crate) supports_oidc_login: bool,
25+
pub(crate) supports_sso_login: bool,
2526
pub(crate) supported_oidc_prompts: Vec<OidcPrompt>,
2627
pub(crate) supports_password_login: bool,
2728
}
@@ -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: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,12 +336,14 @@ impl Client {
336336
};
337337

338338
let supports_password_login = self.supports_password_login().await.ok().unwrap_or(false);
339+
let supports_sso_login = self.supports_sso_login().await.ok().unwrap_or(false);
339340
let sliding_sync_version = self.sliding_sync_version();
340341

341342
Arc::new(HomeserverLoginDetails {
342343
url: self.homeserver(),
343344
sliding_sync_version,
344345
supports_oidc_login,
346+
supports_sso_login,
345347
supported_oidc_prompts,
346348
supports_password_login,
347349
})
@@ -743,6 +745,16 @@ impl Client {
743745
.any(|login_type| matches!(login_type, get_login_types::v3::LoginType::Password(_)));
744746
Ok(supports_password)
745747
}
748+
749+
/// Whether or not the client's homeserver supports the legacy SSO login flow.
750+
pub(crate) async fn supports_sso_login(&self) -> anyhow::Result<bool> {
751+
let login_types = self.inner.matrix_auth().get_login_types().await?;
752+
let supports_password = login_types
753+
.flows
754+
.iter()
755+
.any(|login_type| matches!(login_type, get_login_types::v3::LoginType::Sso(_)));
756+
Ok(supports_password)
757+
}
746758
}
747759

748760
#[matrix_sdk_ffi_macros::export]

0 commit comments

Comments
 (0)