Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1089 mettre en place le nouveau flow sso #1094

Merged
merged 28 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
1d6502e
Reset Element Screens
Sep 16, 2024
b6ce53c
Introduce Tchap heavily customized screens
Sep 16, 2024
9383164
Call Tchap screens from coordinators
Sep 16, 2024
b684962
Introduce Login state parameter to force login mode (Password/SSO)
Sep 16, 2024
64c6ebe
Transmit Login mode from Coordinator to Views
Sep 16, 2024
a459884
Update UI States for login mode
Sep 16, 2024
6f616d0
Insert web link to AgentConnect website
Sep 16, 2024
762901f
Update DevTchap icon
Sep 16, 2024
36a4966
Enable flag to give priority to reauthenticate by SSO
Sep 25, 2024
229fef7
Enable Secrets reset reauthentication by AuthenticationSession
Sep 25, 2024
e5b8130
Dismiss reauthentication view after usage
Sep 25, 2024
3fe90e0
Update login email placeholder
Sep 25, 2024
447087c
Handle SSO Reauthentication on cross-signing reset
Sep 25, 2024
fbde3c6
Enable SSO view BackButton customisation
Sep 25, 2024
a54391c
Customize SSO BackButton
Sep 25, 2024
b6149c2
Set SSO Presentation Sheets modal
Sep 25, 2024
23cc975
Add changelog
Sep 26, 2024
6c592ab
Use SSO identifier string directly
Oct 7, 2024
fbb79f7
Add Tchap comment on Tchap modification
Oct 7, 2024
d9b0fd7
Remove Tchap extension `Weblinks+Tchap.swift` from RiotShareExtension…
Oct 7, 2024
89424cf
Fix compilation problem for RSE target
Sep 24, 2024
fee53b2
Make `TchapShowVerifyEmailScreen` async to be able to call async `aut…
Sep 24, 2024
fba093c
Remove Tchap unused code
Sep 24, 2024
c78a534
Adaptation de AgentConnect à ProConnect
Sep 25, 2024
a4451f3
Add changelog
Sep 26, 2024
94b4202
Update loading animation after login (don't display Element logo anym…
Oct 2, 2024
fd78a72
Revert DEV changes
Oct 7, 2024
a8f565f
Merge branch 'develop' into 1089-mettre-en-place-le-nouveau-flow-sso
NicolasBuquet Oct 7, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Btchap/Config/BuildSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ final class BuildSettings: NSObject {
static let applicationHelpUrlString = "https://www.beta.tchap.gouv.fr/faq"
static let applicationServicesStatusUrlString = "https://status.tchap.numerique.gouv.fr/"
static let applicationAcceptableUsePolicyUrlString = ""

static let proConnectInfoUrlString = "https://proconnect.gouv.fr/"

// MARK: - Matrix permalinks
// Hosts/Paths for URLs that will considered as valid permalinks. Those permalinks are opened within the app.
static let permalinkSupportedHosts: [String: [String]] = [
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions DevTchap/Config/BuildSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ final class BuildSettings: NSObject {
static let serverUrlPrefix = "https://matrix."
static let preferredIdentityServerNames = [
"dev01.tchap.incubateur.net",
"dev02.tchap.incubateur.net"
// "dev02.tchap.incubateur.net"
NicolasBuquet marked this conversation as resolved.
Show resolved Hide resolved
]
static let otherIdentityServerNames: [String] = [
"ext01.tchap.incubateur.net"
Expand All @@ -123,7 +123,7 @@ final class BuildSettings: NSObject {
static let applicationHelpUrlString = "https://www.tchap.incubateur.net/faq"
static let applicationServicesStatusUrlString = "https://status.tchap.numerique.gouv.fr/"
static let applicationAcceptableUsePolicyUrlString = ""

static let proConnectInfoUrlString = "https://proconnect.gouv.fr/"

// MARK: - Matrix permalinks
// Hosts/Paths for URLs that will considered as valid permalinks. Those permalinks are opened within the app.
Expand Down
104 changes: 0 additions & 104 deletions Riot.xcworkspace/xcshareddata/swiftpm/Package.resolved

This file was deleted.

2 changes: 1 addition & 1 deletion Riot/Assets/fr.lproj/Vector.strings
Original file line number Diff line number Diff line change
Expand Up @@ -2299,7 +2299,7 @@
"authentication_verify_email_waiting_hint" = "Vous n’avez pas reçu l’e-mail ?";
/* The placeholder will show the email address that was entered. */
"authentication_verify_email_waiting_message" = "Suivez les instructions envoyées à %@";
"authentication_verify_email_text_field_placeholder" = "Adresse mail"; // Tchap
"authentication_verify_email_text_field_placeholder" = "Adresse mail professionnelle"; // Tchap
/* The placeholder will show the homeserver's domain */
"authentication_verify_email_input_message" = "%@ doit vérifier votre compte";
"authentication_verify_email_input_title" = "Entrez votre e-mail";
Expand Down
64 changes: 47 additions & 17 deletions Riot/Modules/Authentication/AuthenticationCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ final class AuthenticationCoordinator: NSObject, AuthenticationCoordinatorProtoc

enum EntryPoint {
case registration
case login
// Tchap: allow override home server's preferred login mode
// case login
case login(LoginMode? = nil)
}

// MARK: - Properties
Expand Down Expand Up @@ -88,9 +90,17 @@ final class AuthenticationCoordinator: NSObject, AuthenticationCoordinatorProtoc

// MARK: - Public

// Tchap: allow override home server's preferred login mode
func start() {
start(forcedAuthenticationMode: nil)
}

// Tchap: allow override home server's preferred login mode
func start(forcedAuthenticationMode: LoginMode? = nil) {
Task { @MainActor in
await startAuthenticationFlow()
// Tchap: allow override home server's preferred login mode
// await startAuthenticationFlow()
await startAuthenticationFlow(forcedAuthenticationMode: forcedAuthenticationMode)
callback?(.didStart)
authenticationService.delegate = self
}
Expand All @@ -114,7 +124,9 @@ final class AuthenticationCoordinator: NSObject, AuthenticationCoordinatorProtoc
// MARK: - Private

/// Starts the authentication flow.
@MainActor private func startAuthenticationFlow() async {
// Tchap: allow override home server's preferred login mode
// @MainActor private func startAuthenticationFlow() async {
@MainActor private func startAuthenticationFlow(forcedAuthenticationMode: LoginMode? = nil) async {
if let softLogoutCredentials = authenticationService.softLogoutCredentials,
let homeserverAddress = softLogoutCredentials.homeServer {
do {
Expand All @@ -129,22 +141,31 @@ final class AuthenticationCoordinator: NSObject, AuthenticationCoordinatorProtoc
return
}

let flow: AuthenticationFlow = initialScreen == .login ? .login : .register
// Tchap: allow override home server's preferred login mode
// let flow: AuthenticationFlow = initialScreen == .login ? .login : .register
let flow: AuthenticationFlow = {
if case .login(_) = initialScreen {
return .login
} else {
return .register
}
}()

// Check if the user must select a server
if BuildSettings.forceHomeserverSelection, authenticationService.provisioningLink?.homeserverUrl == nil {
showServerSelectionScreen(for: flow)
return
}

do {
// Start the flow (if homeserverAddress is nil, the default server will be used).
try await authenticationService.startFlow(flow)
} catch {
MXLog.error("[AuthenticationCoordinator] start: Failed to start, showing server selection.")
showServerSelectionScreen(for: flow)
return
}
// Tchap: Don't use default home server
// do {
// // Start the flow (if homeserverAddress is nil, the default server will be used).
// try await authenticationService.startFlow(flow)
// } catch {
// MXLog.error("[AuthenticationCoordinator] start: Failed to start, showing server selection.")
// showServerSelectionScreen(for: flow)
// return
// }

switch initialScreen {
case .registration:
Expand All @@ -153,13 +174,15 @@ final class AuthenticationCoordinator: NSObject, AuthenticationCoordinatorProtoc
} else {
// Tchap: force email registration mode
// showRegistrationScreen()
TchapShowVerifyEmailScreen()
await TchapShowVerifyEmailScreen()
}
case .login:
if authenticationService.state.homeserver.needsLoginFallback {
showFallback(for: flow)
} else {
showLoginScreen()
// Tchap: allow override home server's preferred login mode
// showLoginScreen()
showLoginScreen(forcedAuthenticationMode: forcedAuthenticationMode)
}
}
}
Expand Down Expand Up @@ -262,13 +285,17 @@ final class AuthenticationCoordinator: NSObject, AuthenticationCoordinatorProtoc
// MARK: - Login

/// Shows the login screen.
@MainActor private func showLoginScreen() {
// Tchap: allow override home server's preferred login mode
// @MainActor private func showLoginScreen() {
@MainActor private func showLoginScreen(forcedAuthenticationMode: LoginMode? = nil) {
MXLog.debug("[AuthenticationCoordinator] showLoginScreen")

let homeserver = authenticationService.state.homeserver
let parameters = AuthenticationLoginCoordinatorParameters(navigationRouter: navigationRouter,
authenticationService: authenticationService,
loginMode: homeserver.preferredLoginMode)
// Tchap: allow override home server's preferred login mode
// loginMode: homeserver.preferredLoginMode)
loginMode: forcedAuthenticationMode ?? homeserver.preferredLoginMode)
let coordinator = AuthenticationLoginCoordinator(parameters: parameters)
coordinator.callback = { [weak self, weak coordinator] result in
guard let self = self, let coordinator = coordinator else { return }
Expand Down Expand Up @@ -383,9 +410,12 @@ final class AuthenticationCoordinator: NSObject, AuthenticationCoordinatorProtoc

// Tchap: start Registration with VerifyEmail screen
/// Shows the login screen.
@MainActor private func TchapShowVerifyEmailScreen() {
@MainActor private func TchapShowVerifyEmailScreen() async {
MXLog.debug("[AuthenticationCoordinator] TchapShowVerifyEmailScreen")

// Call `startFlow` here to get `registrationWizard` initialized.
try? await authenticationService.startFlow(.register)

guard let registrationWizard = authenticationService.registrationWizard else {
MXLog.failure("[AuthenticationCoordinator] showStage: Missing the RegistrationWizard needed to complete the stage.")
displayError(message: VectorL10n.errorCommonMessage)
Expand Down
37 changes: 35 additions & 2 deletions Riot/Modules/CrossSigning/Setup/CrossSigningSetupCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ final class CrossSigningSetupCoordinator: CrossSigningSetupCoordinatorType {
// MARK: - Public methods

func start() {
self.showReauthentication()
// Tchap: launch classic crossiging without authentication parameters
// to trigger real requets to backend, with real keys.
// This will trigger a 401 reponse that will launch the SSO reauthentication.
// self.showReauthentication()
self.setupCrossSigning(with: [:])
}

func toPresentable() -> UIViewController {
Expand All @@ -71,6 +75,24 @@ final class CrossSigningSetupCoordinator: CrossSigningSetupCoordinatorType {
coordinator.start()
}

// Tchap: reauthenticate with session information (used by SSO reauthentication)
private func showReauthentication(with session: MXAuthenticationSession) {

let setupCrossSigningRequest = self.crossSigningService.setupCrossSigningRequest()

let reauthenticationParameters = ReauthenticationCoordinatorParameters(session: parameters.session,
presenter: parameters.presenter,
title: parameters.title,
message: parameters.message,
authenticationSession: session)

let coordinator = ReauthenticationCoordinator(parameters: reauthenticationParameters)
coordinator.delegate = self
self.add(childCoordinator: coordinator)

coordinator.start()
}

private func setupCrossSigning(with authenticationParameters: [String: Any]) {
guard let crossSigning = self.parameters.session.crypto?.crossSigning else {
return
Expand All @@ -85,7 +107,18 @@ final class CrossSigningSetupCoordinator: CrossSigningSetupCoordinatorType {
guard let self = self else {
return
}
self.delegate?.crossSigningSetupCoordinator(self, didFailWithError: error)

// Tchap: handle 'authentication requested' error (401) from backend
// self.delegate?.crossSigningSetupCoordinator(self, didFailWithError: error)
let nsError = error as NSError
if let jsonResponse = nsError.userInfo[MXHTTPClientErrorResponseDataKey] as? [AnyHashable: Any],
let authenticationSession = MXAuthenticationSession(fromJSON: jsonResponse) {
self.showReauthentication(with: authenticationSession)
}
else {
self.delegate?.crossSigningSetupCoordinator(self, didFailWithError: error)
}

}
}
}
Expand Down
19 changes: 19 additions & 0 deletions Riot/Modules/LaunchLoading/LaunchLoadingView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,33 @@ final class LaunchLoadingView: UIView, NibLoadable, Themable {
animationTimeline.play()
self.animationTimeline = animationTimeline

// Tchap: setup custom loading view.
tchapSetupLoadingView()

progressContainer.isHidden = true
}

// Tchap: replace Element logo loadng animation by a simple UIActivityIndicatorView.
private func tchapSetupLoadingView() {
let tchapAnimationView = UIActivityIndicatorView(style: .large)
self.addSubview(tchapAnimationView)
tchapAnimationView.translatesAutoresizingMaskIntoConstraints = false
tchapAnimationView.centerXAnchor.constraint(equalTo: self.centerXAnchor).isActive = true
tchapAnimationView.centerYAnchor.constraint(equalTo: self.centerYAnchor).isActive = true
tchapAnimationView.startAnimating()

// Hide Element aninmated logo.
animationView.isHidden = true
}

// MARK: - Public

func update(theme: Theme) {
self.backgroundColor = theme.backgroundColor
self.animationView.backgroundColor = theme.backgroundColor

// Tchap: Set progress view to Tchap color.
progressView.progressTintColor = theme.tintColor
}
}

Expand Down
3 changes: 3 additions & 0 deletions Riot/Modules/MatrixKit/Controllers/MXKWebViewViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,7 @@
*/
@property (nonatomic) NSString *localHTMLFile;

// Tchap: give access to backButton to allow a 'Cancel' functionnality.
- (void)setBackButton:(UIBarButtonItem *)button;

@end
5 changes: 5 additions & 0 deletions Riot/Modules/MatrixKit/Controllers/MXKWebViewViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,11 @@ - (void)goBack
}
}

// Tchap: give access to backButton to allow a 'Cancel' functionnality.
- (void)setBackButton:(UIBarButtonItem *)button {
backButton = button;
}

#pragma mark - WKNavigationDelegate

- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation
Expand Down
Loading
Loading