File tree Expand file tree Collapse file tree 3 files changed +32
-13
lines changed Expand file tree Collapse file tree 3 files changed +32
-13
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,13 @@ All notable changes to this project will be documented in this file.
6
6
7
7
## [ Unreleased] - ReleaseDate
8
8
9
+ ### Features:
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
+
9
16
### Breaking changes:
10
17
11
18
- ` Client::url_for_oidc ` now allows requesting additional scopes for the OAuth2 authorization code grant.
Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ pub struct HomeserverLoginDetails {
23
23
pub ( crate ) sliding_sync_version : SlidingSyncVersion ,
24
24
pub ( crate ) supports_oidc_login : bool ,
25
25
pub ( crate ) supported_oidc_prompts : Vec < OidcPrompt > ,
26
+ pub ( crate ) supports_sso_login : bool ,
26
27
pub ( crate ) supports_password_login : bool ,
27
28
}
28
29
@@ -43,6 +44,11 @@ impl HomeserverLoginDetails {
43
44
self . supports_oidc_login
44
45
}
45
46
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
+
46
52
/// The prompts advertised by the authentication issuer for use in the login
47
53
/// URL.
48
54
pub fn supported_oidc_prompts ( & self ) -> Vec < OidcPrompt > {
Original file line number Diff line number Diff line change @@ -341,14 +341,32 @@ impl Client {
341
341
}
342
342
} ;
343
343
344
- let supports_password_login = self . supports_password_login ( ) . await . ok ( ) . unwrap_or ( false ) ;
344
+ let login_types = self . inner . matrix_auth ( ) . get_login_types ( ) . await . ok ( ) ;
345
+ let supports_password_login = login_types
346
+ . as_ref ( )
347
+ . map ( |login_types| {
348
+ login_types. flows . iter ( ) . any ( |login_type| {
349
+ matches ! ( login_type, get_login_types:: v3:: LoginType :: Password ( _) )
350
+ } )
351
+ } )
352
+ . unwrap_or ( false ) ;
353
+ let supports_sso_login = login_types
354
+ . as_ref ( )
355
+ . map ( |login_types| {
356
+ login_types
357
+ . flows
358
+ . iter ( )
359
+ . any ( |login_type| matches ! ( login_type, get_login_types:: v3:: LoginType :: Sso ( _) ) )
360
+ } )
361
+ . unwrap_or ( false ) ;
345
362
let sliding_sync_version = self . sliding_sync_version ( ) ;
346
363
347
364
Arc :: new ( HomeserverLoginDetails {
348
365
url : self . homeserver ( ) ,
349
366
sliding_sync_version,
350
367
supports_oidc_login,
351
368
supported_oidc_prompts,
369
+ supports_sso_login,
352
370
supports_password_login,
353
371
} )
354
372
}
@@ -808,18 +826,6 @@ impl Client {
808
826
}
809
827
}
810
828
811
- impl Client {
812
- /// Whether or not the client's homeserver supports the password login flow.
813
- pub ( crate ) async fn supports_password_login ( & self ) -> anyhow:: Result < bool > {
814
- let login_types = self . inner . matrix_auth ( ) . get_login_types ( ) . await ?;
815
- let supports_password = login_types
816
- . flows
817
- . iter ( )
818
- . any ( |login_type| matches ! ( login_type, get_login_types:: v3:: LoginType :: Password ( _) ) ) ;
819
- Ok ( supports_password)
820
- }
821
- }
822
-
823
829
#[ matrix_sdk_ffi_macros:: export]
824
830
impl Client {
825
831
/// The sliding sync version.
You can’t perform that action at this time.
0 commit comments