Skip to content

Commit

Permalink
Finish hotfix_Riot_2715
Browse files Browse the repository at this point in the history
  • Loading branch information
manuroe committed Sep 16, 2019
2 parents 9ab4dd6 + b6c63ab commit a51e0cb
Show file tree
Hide file tree
Showing 8 changed files with 355 additions and 9 deletions.
6 changes: 6 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
Changes in 0.9.4 (2019-09-13)
===============================================

Improvements:
* Authentication: Improve the webview used for SSO (#2715).

Changes in 0.9.3 (2019-09-10)
===============================================

Expand Down
14 changes: 14 additions & 0 deletions Riot.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
3232ABBC2257BE6500AD6A5C /* DeviceVerificationVerifyViewAction.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3232ABB42257BE6400AD6A5C /* DeviceVerificationVerifyViewAction.swift */; };
3232ABC022594C0900AD6A5C /* VerifyEmojiCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3232ABBF22594C0900AD6A5C /* VerifyEmojiCollectionViewCell.swift */; };
3232ABC2225B996200AD6A5C /* Themable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3232ABC1225B996100AD6A5C /* Themable.swift */; };
323AB947232BD74600C1451F /* AuthFallBackViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 323AB946232BD74600C1451F /* AuthFallBackViewController.m */; };
324A204F225FC571004FE8B0 /* DeviceVerificationIncomingViewController.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 324A2047225FC571004FE8B0 /* DeviceVerificationIncomingViewController.storyboard */; };
324A2050225FC571004FE8B0 /* DeviceVerificationIncomingViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 324A2048225FC571004FE8B0 /* DeviceVerificationIncomingViewController.swift */; };
324A2051225FC571004FE8B0 /* DeviceVerificationIncomingViewState.swift in Sources */ = {isa = PBXBuildFile; fileRef = 324A2049225FC571004FE8B0 /* DeviceVerificationIncomingViewState.swift */; };
Expand Down Expand Up @@ -651,6 +652,8 @@
3232ABB42257BE6400AD6A5C /* DeviceVerificationVerifyViewAction.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DeviceVerificationVerifyViewAction.swift; sourceTree = "<group>"; };
3232ABBF22594C0900AD6A5C /* VerifyEmojiCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VerifyEmojiCollectionViewCell.swift; sourceTree = "<group>"; };
3232ABC1225B996100AD6A5C /* Themable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Themable.swift; sourceTree = "<group>"; };
323AB945232BD74600C1451F /* AuthFallBackViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AuthFallBackViewController.h; sourceTree = "<group>"; };
323AB946232BD74600C1451F /* AuthFallBackViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AuthFallBackViewController.m; sourceTree = "<group>"; };
324A2047225FC571004FE8B0 /* DeviceVerificationIncomingViewController.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = DeviceVerificationIncomingViewController.storyboard; sourceTree = "<group>"; };
324A2048225FC571004FE8B0 /* DeviceVerificationIncomingViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DeviceVerificationIncomingViewController.swift; sourceTree = "<group>"; };
324A2049225FC571004FE8B0 /* DeviceVerificationIncomingViewState.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DeviceVerificationIncomingViewState.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1584,6 +1587,15 @@
path = Views;
sourceTree = "<group>";
};
323AB944232BD71900C1451F /* Fallback */ = {
isa = PBXGroup;
children = (
323AB945232BD74600C1451F /* AuthFallBackViewController.h */,
323AB946232BD74600C1451F /* AuthFallBackViewController.m */,
);
path = Fallback;
sourceTree = "<group>";
};
324A2046225FC571004FE8B0 /* Incoming */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -2254,6 +2266,7 @@
B1B5568420EE6C4C00210D55 /* Home */ = {
isa = PBXGroup;
children = (
323AB944232BD71900C1451F /* Fallback */,
B1B5568620EE6C4C00210D55 /* HomeViewController.h */,
B1B5568520EE6C4C00210D55 /* HomeViewController.m */,
B1B5593D20EF7BD000210D55 /* Views */,
Expand Down Expand Up @@ -4428,6 +4441,7 @@
B1B558FA20EF768F00210D55 /* RoomMembershipBubbleCell.m in Sources */,
3232ABA1225730E100AD6A5C /* DeviceVerificationCoordinatorType.swift in Sources */,
B1C562D9228C0B760037F12A /* RoomContextualMenuItem.swift in Sources */,
323AB947232BD74600C1451F /* AuthFallBackViewController.m in Sources */,
B1C562E1228C7C8C0037F12A /* RoomContextualMenuToolbarView.swift in Sources */,
B1B557BF20EF5B4500210D55 /* DisabledRoomInputToolbarView.m in Sources */,
B1B5578620EF564900210D55 /* GroupTableViewCellWithSwitch.m in Sources */,
Expand Down
75 changes: 72 additions & 3 deletions Riot/Modules/Authentication/AuthenticationViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@

#import "AuthInputsView.h"
#import "ForgotPasswordInputsView.h"
#import "AuthFallBackViewController.h"

@interface AuthenticationViewController ()
@interface AuthenticationViewController () <AuthFallBackViewControllerDelegate>
{
/**
Store the potential login error received by using a default homeserver different from matrix.org
Expand All @@ -46,6 +47,8 @@ @interface AuthenticationViewController ()
Server discovery.
*/
MXAutoDiscovery *autoDiscovery;

AuthFallBackViewController *authFallBackViewController;
}

@end
Expand Down Expand Up @@ -408,6 +411,74 @@ - (void)setUserInteractionEnabled:(BOOL)userInteractionEnabled
}
}


#pragma mark - Fallback URL display

- (void)showAuthenticationFallBackView:(NSString*)fallbackPage
{
// Skip MatrixKit and use a VC instead
if (self.softLogoutCredentials)
{
// Add device_id as query param of the fallback
NSURLComponents *components = [[NSURLComponents alloc] initWithString:fallbackPage];

NSMutableArray<NSURLQueryItem*> *queryItems = [components.queryItems mutableCopy];
if (!queryItems)
{
queryItems = [NSMutableArray array];
}

[queryItems addObject:[NSURLQueryItem queryItemWithName:@"device_id"
value:self.softLogoutCredentials.deviceId]];

components.queryItems = queryItems;

fallbackPage = components.URL.absoluteString;
}

[self showAuthenticationFallBackViewController:fallbackPage];
}

- (void)showAuthenticationFallBackViewController:(NSString*)fallbackPage
{
authFallBackViewController = [[AuthFallBackViewController alloc] initWithURL:fallbackPage];
authFallBackViewController.delegate = self;


authFallBackViewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(dismissFallBackViewController:)];

UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:authFallBackViewController];
[self presentViewController:navigationController animated:YES completion:nil];
}

- (void)dismissFallBackViewController:(id)sender
{
[authFallBackViewController dismissViewControllerAnimated:YES completion:nil];
authFallBackViewController = nil;
}


#pragma mark AuthFallBackViewControllerDelegate

- (void)authFallBackViewController:(AuthFallBackViewController *)authFallBackViewController
didLoginWithLoginResponse:(MXLoginResponse *)loginResponse
{
[authFallBackViewController dismissViewControllerAnimated:YES completion:^{

MXCredentials *credentials = [[MXCredentials alloc] initWithLoginResponse:loginResponse andDefaultCredentials:nil];
[self onSuccessfulLogin:credentials];
}];

authFallBackViewController = nil;
}


- (void)authFallBackViewControllerDidClose:(AuthFallBackViewController *)authFallBackViewController
{
[self dismissFallBackViewController:nil];
}


- (void)setSoftLogoutCredentials:(MXCredentials *)softLogoutCredentials
{
[super setSoftLogoutCredentials:softLogoutCredentials];
Expand Down Expand Up @@ -693,8 +764,6 @@ - (IBAction)onButtonPressed:(id)sender
{
// Do SSO using the fallback URL
[self showAuthenticationFallBackView];

[ThemeService.shared.theme applyStyleOnNavigationBar:self.navigationController.navigationBar];
}
else if (sender == self.softLogoutClearDataButton)
{
Expand Down
40 changes: 40 additions & 0 deletions Riot/Modules/Home/Fallback/AuthFallBackViewController.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
Copyright 2019 New Vector Ltd
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

#import "WebViewViewController.h"

NS_ASSUME_NONNULL_BEGIN

@class AuthFallBackViewController;
@protocol AuthFallBackViewControllerDelegate

- (void)authFallBackViewController:(AuthFallBackViewController*)authFallBackViewController didLoginWithLoginResponse:(MXLoginResponse*)loginResponse;
- (void)authFallBackViewControllerDidClose:(AuthFallBackViewController*)authFallBackViewController;

@end


/**
`AuthFallBackViewController` handles the display of a Matrix fallback URL for
login, registration and Single-Sign-On.
*/
@interface AuthFallBackViewController : WebViewViewController

@property (nonatomic, weak, nullable) id<AuthFallBackViewControllerDelegate> delegate;

@end

NS_ASSUME_NONNULL_END
Loading

0 comments on commit a51e0cb

Please sign in to comment.