Skip to content

Commit dfbcfc1

Browse files
committed
chore(ffi): Expose support for registration through OIDC in the login details.
1 parent ca1d829 commit dfbcfc1

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ pub struct HomeserverLoginDetails {
2626
pub(crate) url: String,
2727
pub(crate) sliding_sync_version: SlidingSyncVersion,
2828
pub(crate) supports_oidc_login: bool,
29+
pub(crate) supports_oidc_registration: bool,
2930
pub(crate) supports_password_login: bool,
3031
}
3132

@@ -46,6 +47,11 @@ impl HomeserverLoginDetails {
4647
self.supports_oidc_login
4748
}
4849

50+
/// Whether the current homeserver supports registration using OIDC.
51+
pub fn supports_oidc_registration(&self) -> bool {
52+
self.supports_oidc_registration
53+
}
54+
4955
/// Whether the current homeserver supports the password login flow.
5056
pub fn supports_password_login(&self) -> bool {
5157
self.supports_password_login

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

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,14 +266,29 @@ impl Client {
266266
impl Client {
267267
/// Information about login options for the client's homeserver.
268268
pub async fn homeserver_login_details(&self) -> Arc<HomeserverLoginDetails> {
269-
let supports_oidc_login = self.inner.oidc().fetch_authentication_issuer().await.is_ok();
269+
let oidc = self.inner.oidc();
270+
let (supports_oidc_login, supports_oidc_registration) =
271+
if let Ok(issuer) = oidc.fetch_authentication_issuer().await {
272+
if let Ok(metadata) = &oidc.given_provider_metadata(&issuer).await {
273+
metadata
274+
.prompt_values_supported
275+
.as_ref()
276+
.map(|prompts| (true, prompts.contains(&SdkOidcPrompt::Create)))
277+
.unwrap_or((true, false))
278+
} else {
279+
(true, false)
280+
}
281+
} else {
282+
(false, false)
283+
};
270284
let supports_password_login = self.supports_password_login().await.ok().unwrap_or(false);
271285
let sliding_sync_version = self.sliding_sync_version();
272286

273287
Arc::new(HomeserverLoginDetails {
274288
url: self.homeserver(),
275289
sliding_sync_version,
276290
supports_oidc_login,
291+
supports_oidc_registration,
277292
supports_password_login,
278293
})
279294
}

0 commit comments

Comments
 (0)