mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-04 01:20:12 +00:00
Use Safari for OIDC account URL. (#1591)
* Handle RP-Initiated Logout URL. Safari is only used on devices, the simulator doesn't work properly.
This commit is contained in:
@@ -397,19 +397,25 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationCoordinatorDelegate,
|
|||||||
}
|
}
|
||||||
|
|
||||||
Task {
|
Task {
|
||||||
// first log out from the server
|
// First log out from the server
|
||||||
_ = await userSession.clientProxy.logout()
|
let accountLogoutURL = await userSession.clientProxy.logout()
|
||||||
|
|
||||||
// regardless of the result, clear user data
|
// Regardless of the result, clear user data
|
||||||
userSessionStore.logout(userSession: userSession)
|
userSessionStore.logout(userSession: userSession)
|
||||||
tearDownUserSession()
|
tearDownUserSession()
|
||||||
|
|
||||||
// reset analytics
|
// Reset analytics
|
||||||
ServiceLocator.shared.analytics.optOut()
|
ServiceLocator.shared.analytics.optOut()
|
||||||
ServiceLocator.shared.analytics.resetConsentState()
|
ServiceLocator.shared.analytics.resetConsentState()
|
||||||
|
|
||||||
stateMachine.processEvent(.completedSigningOut(isSoft: isSoft))
|
stateMachine.processEvent(.completedSigningOut(isSoft: isSoft))
|
||||||
|
|
||||||
|
// Handle OIDC's RP-Initiated Logout if needed. Don't fallback to an ASWebAuthenticationSession
|
||||||
|
// as it looks weird to show an alert to the user asking them to sign in to their provider.
|
||||||
|
if let accountLogoutURL, UIApplication.shared.canOpenURL(accountLogoutURL) {
|
||||||
|
await UIApplication.shared.open(accountLogoutURL)
|
||||||
|
}
|
||||||
|
|
||||||
hideLoadingIndicator()
|
hideLoadingIndicator()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -88,12 +88,19 @@ final class SettingsScreenCoordinator: CoordinatorProtocol {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Safari never works in the simulator, use a Web Authentication Session instead.
|
#if targetEnvironment(simulator)
|
||||||
accountSettingsPresenter = OIDCAccountSettingsPresenter(accountURL: accountURL, presentationAnchor: window)
|
let canOpenURL = false // Safari can't access the cookie on the iOS 16 simulator 🤷♂️
|
||||||
accountSettingsPresenter?.start()
|
#else
|
||||||
|
let canOpenURL = UIApplication.shared.canOpenURL(accountURL)
|
||||||
|
#endif
|
||||||
|
|
||||||
// Safari isn't working with the shared browser session 😕
|
if canOpenURL {
|
||||||
// UIApplication.shared.open(accountURL)
|
UIApplication.shared.open(accountURL)
|
||||||
|
} else {
|
||||||
|
// Fall back to an ASWebAuthenticationSession to handle the URL inside the app.
|
||||||
|
accountSettingsPresenter = OIDCAccountSettingsPresenter(accountURL: accountURL, presentationAnchor: window)
|
||||||
|
accountSettingsPresenter?.start()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private func presentAnalyticsScreen() {
|
private func presentAnalyticsScreen() {
|
||||||
|
|||||||
@@ -306,13 +306,13 @@ class ClientProxy: ClientProxyProtocol {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func logout() async {
|
func logout() async -> URL? {
|
||||||
await Task.dispatch(on: clientQueue) {
|
await Task.dispatch(on: clientQueue) {
|
||||||
do {
|
do {
|
||||||
// We aren't currently handling the RP initiated sign out URL.
|
return try self.client.logout().flatMap(URL.init(string:))
|
||||||
_ = try self.client.logout()
|
|
||||||
} catch {
|
} catch {
|
||||||
MXLog.error("Failed logging out with error: \(error)")
|
MXLog.error("Failed logging out with error: \(error)")
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ protocol ClientProxyProtocol: AnyObject, MediaLoaderProtocol {
|
|||||||
|
|
||||||
func sessionVerificationControllerProxy() async -> Result<SessionVerificationControllerProxyProtocol, ClientProxyError>
|
func sessionVerificationControllerProxy() async -> Result<SessionVerificationControllerProxyProtocol, ClientProxyError>
|
||||||
|
|
||||||
func logout() async
|
func logout() async -> URL?
|
||||||
|
|
||||||
func setPusher(with configuration: PusherConfiguration) async throws
|
func setPusher(with configuration: PusherConfiguration) async throws
|
||||||
|
|
||||||
|
|||||||
@@ -116,8 +116,8 @@ class MockClientProxy: ClientProxyProtocol {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func logout() async {
|
func logout() async -> URL? {
|
||||||
// no-op
|
nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var setPusherErrorToThrow: Error?
|
var setPusherErrorToThrow: Error?
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
Use Safari for OIDC account management.
|
||||||
Reference in New Issue
Block a user