From 2e86379b2aa94d1015b22491b9a730a79239323a Mon Sep 17 00:00:00 2001 From: manuroe Date: Tue, 10 Sep 2019 11:51:49 +0200 Subject: [PATCH 1/3] Support Riot configuration link to customise HS and IS #2703 --- CHANGES.rst | 6 ++ Riot/AppDelegate.m | 92 +++++++++++++++++++ Riot/Assets/en.lproj/Vector.strings | 2 + Riot/Generated/Strings.swift | 4 + .../AuthenticationViewController.h | 2 + 5 files changed, 106 insertions(+) diff --git a/CHANGES.rst b/CHANGES.rst index 507513d45f..9ad388c8f5 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,3 +1,9 @@ +Changes in 0.9.3 (2019-09-10) +=============================================== + +Improvements: + * Support Riot configuration link to customise HS and IS (#2703). + Changes in 0.9.2 (2019-08-08) =============================================== diff --git a/Riot/AppDelegate.m b/Riot/AppDelegate.m index 9e6cf8f5b4..10b8beeedd 100644 --- a/Riot/AppDelegate.m +++ b/Riot/AppDelegate.m @@ -2100,6 +2100,11 @@ - (BOOL)handleUniversalLink:(NSUserActivity*)userActivity // iOS Patch: fix vector.im urls before using it webURL = [Tools fixURLWithSeveralHashKeys:webURL]; + + if ([webURL.path hasPrefix:@"/config"]) + { + return [self handleServerProvionningLink:webURL]; + } // Manage email validation link if ([webURL.path isEqualToString:@"/_matrix/identity/api/v1/validate/email/submitToken"]) @@ -2547,6 +2552,93 @@ - (void)parseUniversalLinkFragment:(NSString*)fragment outPathParams:(NSArray String { return VectorL10n.tr("Vector", "event_formatter_jitsi_widget_added", p1) diff --git a/Riot/Modules/Authentication/AuthenticationViewController.h b/Riot/Modules/Authentication/AuthenticationViewController.h index 9c24ea4f19..f854a0a1c7 100644 --- a/Riot/Modules/Authentication/AuthenticationViewController.h +++ b/Riot/Modules/Authentication/AuthenticationViewController.h @@ -45,5 +45,7 @@ @property (weak, nonatomic) IBOutlet UILabel *softLogoutClearDataLabel; @property (weak, nonatomic) IBOutlet UIButton *softLogoutClearDataButton; +- (void)showCustomHomeserver:(NSString*)homeserver andIdentityServer:(NSString*)identityServer; + @end From 76923cae112b64bd63d4ca88de9952af81f460e4 Mon Sep 17 00:00:00 2001 From: manuroe Date: Tue, 10 Sep 2019 14:33:41 +0200 Subject: [PATCH 2/3] Authentication: Create a way to filter and prioritise flows (with handleSupportedFlowsInAuthenticationSession). --- CHANGES.rst | 1 + .../AuthenticationViewController.m | 52 +++++++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/CHANGES.rst b/CHANGES.rst index 9ad388c8f5..453202661c 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -3,6 +3,7 @@ Changes in 0.9.3 (2019-09-10) Improvements: * Support Riot configuration link to customise HS and IS (#2703). + * Authentication: Create a way to filter and prioritise flows (with handleSupportedFlowsInAuthenticationSession). Changes in 0.9.2 (2019-08-08) =============================================== diff --git a/Riot/Modules/Authentication/AuthenticationViewController.m b/Riot/Modules/Authentication/AuthenticationViewController.m index d557ec443b..46def1f3a2 100644 --- a/Riot/Modules/Authentication/AuthenticationViewController.m +++ b/Riot/Modules/Authentication/AuthenticationViewController.m @@ -497,9 +497,61 @@ - (void)clearDataAfterSoftLogout }]; } +/** + Filter and prioritise flows supported by the app. + + @param authSession the auth session coming from the HS. + @return a new auth session + */ +- (MXAuthenticationSession*)handleSupportedFlowsInAuthenticationSession:(MXAuthenticationSession *)authSession +{ + MXLoginFlow *ssoFlow; + NSMutableArray *supportedFlows = [NSMutableArray array]; + + for (MXLoginFlow *flow in authSession.flows) + { + // Remove known flows we do not support + if (![flow.type isEqualToString:kMXLoginFlowTypeToken]) + { + NSLog(@"[AuthenticationVC] handleSupportedFlowsInAuthenticationSession: Filter out flow %@", flow.type); + [supportedFlows addObject:flow]; + } + + // Prioritise SSO over other flows + if ([flow.type isEqualToString:kMXLoginFlowTypeSSO] + || [flow.type isEqualToString:kMXLoginFlowTypeCAS]) + { + NSLog(@"[AuthenticationVC] handleSupportedFlowsInAuthenticationSession: Prioritise flow %@", flow.type); + ssoFlow = flow; + break; + } + } + + if (ssoFlow) + { + [supportedFlows removeAllObjects]; + [supportedFlows addObject:ssoFlow]; + } + + if (supportedFlows.count != authSession.flows.count) + { + MXAuthenticationSession *updatedAuthSession = [[MXAuthenticationSession alloc] init]; + updatedAuthSession.session = authSession.session; + updatedAuthSession.params = authSession.params; + updatedAuthSession.flows = supportedFlows; + return updatedAuthSession; + } + else + { + return authSession; + } +} - (void)handleAuthenticationSession:(MXAuthenticationSession *)authSession { + // Make some cleaning from the server response according to what the app supports + authSession = [self handleSupportedFlowsInAuthenticationSession:authSession]; + [super handleAuthenticationSession:authSession]; AuthInputsView *authInputsview; From 4ffe0bd511ce73085c0df955955fa3fae1fef229 Mon Sep 17 00:00:00 2001 From: manuroe Date: Tue, 10 Sep 2019 16:21:32 +0200 Subject: [PATCH 3/3] version++ --- Riot/SupportingFiles/Info.plist | 4 ++-- RiotShareExtension/SupportingFiles/Info.plist | 4 ++-- SiriIntents/Info.plist | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Riot/SupportingFiles/Info.plist b/Riot/SupportingFiles/Info.plist index 2ee99817eb..311996ec82 100644 --- a/Riot/SupportingFiles/Info.plist +++ b/Riot/SupportingFiles/Info.plist @@ -17,11 +17,11 @@ CFBundlePackageType APPL CFBundleShortVersionString - 0.9.2 + 0.9.3 CFBundleSignature ???? CFBundleVersion - 0.9.2 + 0.9.3 ITSAppUsesNonExemptEncryption ITSEncryptionExportComplianceCode diff --git a/RiotShareExtension/SupportingFiles/Info.plist b/RiotShareExtension/SupportingFiles/Info.plist index 4cc7b7bb6d..2653990ba9 100644 --- a/RiotShareExtension/SupportingFiles/Info.plist +++ b/RiotShareExtension/SupportingFiles/Info.plist @@ -17,9 +17,9 @@ CFBundlePackageType XPC! CFBundleShortVersionString - 0.9.2 + 0.9.3 CFBundleVersion - 0.9.2 + 0.9.3 NSExtension NSExtensionAttributes diff --git a/SiriIntents/Info.plist b/SiriIntents/Info.plist index 804ac1c8f0..b91b0372a7 100644 --- a/SiriIntents/Info.plist +++ b/SiriIntents/Info.plist @@ -17,9 +17,9 @@ CFBundlePackageType XPC! CFBundleShortVersionString - 0.9.2 + 0.9.3 CFBundleVersion - 0.9.2 + 0.9.3 NSExtension NSExtensionAttributes