From 39a72ecd17a350883eff6aeb2b70de45b564d471 Mon Sep 17 00:00:00 2001 From: Jeroen Leenarts Date: Tue, 6 Mar 2018 22:22:12 +0100 Subject: [PATCH] Add entitlement and rewire most of the app to use an universal link. Needs compeion and testing. Related to #23. --- EduVPN.xcodeproj/project.pbxproj | 9 +++++++++ EduVPN/AppDelegate.swift | 6 ++++++ EduVPN/EduVPN.entitlements | 11 +++++++++++ EduVPN/Networking/ApiService.swift | 1 + 4 files changed, 27 insertions(+) create mode 100644 EduVPN/EduVPN.entitlements diff --git a/EduVPN.xcodeproj/project.pbxproj b/EduVPN.xcodeproj/project.pbxproj index b28d26ba..856727d8 100644 --- a/EduVPN.xcodeproj/project.pbxproj +++ b/EduVPN.xcodeproj/project.pbxproj @@ -86,6 +86,7 @@ 4A62C8B71FB03B47007D3FAA /* KeyboardWrapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeyboardWrapper.swift; sourceTree = ""; }; 4A7D1E4E1F4B24E4009F1402 /* ProfileModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ProfileModel.swift; sourceTree = ""; }; 4A81DF9B2003BFB7002827A8 /* CertificateModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CertificateModel.swift; sourceTree = ""; }; + 4A84E276204F3A5B00E51EFE /* EduVPN.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = EduVPN.entitlements; sourceTree = ""; }; 4A8D241E1F3976A2004A9343 /* ProfilesViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ProfilesViewController.swift; sourceTree = ""; }; 4A8D24201F3976FC004A9343 /* ProviderType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ProviderType.swift; sourceTree = ""; }; 4A8D24341F3A40F2004A9343 /* InstanceInfoModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = InstanceInfoModel.swift; sourceTree = ""; }; @@ -199,6 +200,7 @@ 4AAC1F781F2D0E3400DD0252 /* EduVPN */ = { isa = PBXGroup; children = ( + 4A84E276204F3A5B00E51EFE /* EduVPN.entitlements */, 4A983B751F397223004F82D5 /* Coordinators */, 4AD0AD601F3508DD006E1337 /* Models */, 4AD0AD5B1F35045E006E1337 /* ViewControllers */, @@ -364,6 +366,11 @@ DevelopmentTeam = T4CMEHXPLL; LastSwiftMigration = 0900; ProvisioningStyle = Manual; + SystemCapabilities = { + com.apple.SafariKeychain = { + enabled = 1; + }; + }; }; 4AAC1F891F2D0E3400DD0252 = { CreatedOnToolsVersion = 8.3.3; @@ -763,6 +770,7 @@ baseConfigurationReference = 8828097AD8E6A8FAE767E4D9 /* Pods-EduVPN.debug.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_ENTITLEMENTS = EduVPN/EduVPN.entitlements; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Manual; DEVELOPMENT_TEAM = T4CMEHXPLL; @@ -782,6 +790,7 @@ baseConfigurationReference = BF41F680EFA1657A481FC709 /* Pods-EduVPN.release.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_ENTITLEMENTS = EduVPN/EduVPN.entitlements; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Manual; DEVELOPMENT_TEAM = T4CMEHXPLL; diff --git a/EduVPN/AppDelegate.swift b/EduVPN/AppDelegate.swift index 4cab5a49..75797de4 100644 --- a/EduVPN/AppDelegate.swift +++ b/EduVPN/AppDelegate.swift @@ -48,6 +48,12 @@ class AppDelegate: UIResponder, UIApplicationDelegate { func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey: Any] = [:]) -> Bool { return appCoordinator.resumeAuthorizationFlow(url: url) == true } + + func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([Any]?) -> Void) -> Bool { + + guard let url = userActivity.webpageURL else { return false } + return appCoordinator.resumeAuthorizationFlow(url: url) == true + } } extension AppDelegate: UNUserNotificationCenterDelegate { diff --git a/EduVPN/EduVPN.entitlements b/EduVPN/EduVPN.entitlements new file mode 100644 index 00000000..4e8b3065 --- /dev/null +++ b/EduVPN/EduVPN.entitlements @@ -0,0 +1,11 @@ + + + + + com.apple.developer.associated-domains + + applinks:*.eduvpn.org + applinks:eduvpn.org + + + diff --git a/EduVPN/Networking/ApiService.swift b/EduVPN/Networking/ApiService.swift index 4b8a1468..9ab7f58c 100644 --- a/EduVPN/Networking/ApiService.swift +++ b/EduVPN/Networking/ApiService.swift @@ -93,6 +93,7 @@ class DynamicApiProvider: MoyaProvider { public func authorize(presentingViewController: UIViewController) -> Promise { let request = OIDAuthorizationRequest(configuration: authConfig, clientId: "org.eduvpn.app.ios", scopes: ["config"], redirectURL: URL(string: "org.eduvpn.app:/api/callback")!, responseType: OIDResponseTypeCode, additionalParameters: nil) + //TODO: Switch to use https://eduvpn.org/auth/app/redirect/[development/] return Promise(resolver: { seal in currentAuthorizationFlow = OIDAuthState.authState(byPresenting: request, presenting: presentingViewController, callback: { (authState, error) in