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

Enable SSO handling (login and UIA) by feature flag #1111

Merged
merged 1 commit into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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: 3 additions & 0 deletions Btchap/Config/BuildSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,9 @@ final class BuildSettings: NSObject {
tchapFeatureAnyFeature: [ tchapFeatureAnyHomeServer ]
]

// Tchap: handle SSO feature flag. Presents SSO button on Onboarding screen and give priority to SSO on UIA.
static let tchapFeatureHandleSSO = false

// MARK: - Side Menu
static let enableSideMenu: Bool = true && !newAppLayoutEnabled
static let sideMenuShowInviteFriends: Bool = true
Expand Down
3 changes: 3 additions & 0 deletions DevTchap/Config/BuildSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,9 @@ final class BuildSettings: NSObject {
tchapFeatureAnyFeature: [ tchapFeatureAnyHomeServer ]
]

// Tchap: handle SSO feature flag. Presents SSO button on Onboarding screen and give priority to SSO on UIA.
static let tchapFeatureHandleSSO = true

// MARK: - Side Menu
static let enableSideMenu: Bool = true && !newAppLayoutEnabled
static let sideMenuShowInviteFriends: Bool = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ enum DeactivateAccountServiceError: Error {
/// - Parameter authenticationSession: The authentication session to be used.
/// - Returns: A tuple containing the required authentication method along with a URL for fallback if necessary.
private func handleAuthenticationSession(_ authenticationSession: MXAuthenticationSession) throws -> (DeactivateAccountAuthentication, URL?) {
// Tchap: give priority to SSO authentication
// guard let nextStage = uiaService.firstUncompletedFlowIdentifier(in: authenticationSession) else {
guard let nextStage = uiaService.firstUncompletedFlowIdentifier(in: authenticationSession, priorityToSso: true) else {
// Tchap: give priority to SSO authentication if SSO handling is activated by feature flag.
// guard let nextStage = uiaService.firstUncompletedFlowIdentifier(in: authenticationSession) else {
guard let nextStage = uiaService.firstUncompletedFlowIdentifier(in: authenticationSession, priorityToSso: BuildSettings.tchapFeatureHandleSSO) else {
MXLog.error("[DeactivateAccountService] handleAuthenticationSession: Failed to determine the next stage.")
throw DeactivateAccountServiceError.missingStage
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,9 @@ final class UserInteractiveAuthenticationService: NSObject {
/// - Returns: The fallback URL for the first uncompleted stage found.
func firstUncompletedStageAuthenticationFallbackURL(for authenticationSession: MXAuthenticationSession) -> URL? {
guard let sessiondId = authenticationSession.session,
// Tchap: give priority to SSO authentication
// Tchap: give priority to SSO authentication if SSO handling is activated by feature flag.
// let firstUncompletedStageIdentifier = self.firstUncompletedFlowIdentifier(in: authenticationSession) else {
let firstUncompletedStageIdentifier = self.firstUncompletedFlowIdentifier(in: authenticationSession, priorityToSso: true) else {
let firstUncompletedStageIdentifier = self.firstUncompletedFlowIdentifier(in: authenticationSession, priorityToSso: BuildSettings.tchapFeatureHandleSSO) else {
yostyle marked this conversation as resolved.
Show resolved Hide resolved
return nil
}
return self.authenticationFallbackURL(for: firstUncompletedStageIdentifier, sessionId: sessiondId)
Expand Down Expand Up @@ -261,8 +261,8 @@ final class UserInteractiveAuthenticationService: NSObject {
let completedStagesSet = NSOrderedSet(array: completedStages)
uncompletedStages.minus(completedStagesSet)

// Tchap
if uncompletedStages.contains(kMXLoginFlowTypeSSO) {
// Tchap: return SSO if priority is given to SSO login flow type and SSO flow type is available on the homeServer.
if priorityToSso && uncompletedStages.contains(kMXLoginFlowTypeSSO) {
return kMXLoginFlowTypeSSO
}

Expand All @@ -284,7 +284,7 @@ final class UserInteractiveAuthenticationService: NSObject {
// Tchap
/// Check if an array of login flows contains "m.login.sso" flow.
func tchapHasSsoFlowAvailable(authenticationSession: MXAuthenticationSession) -> Bool {
return self.firstUncompletedFlowIdentifier(in: authenticationSession, priorityToSso: true) == kMXLoginFlowTypeSSO
return self.firstUncompletedFlowIdentifier(in: authenticationSession, priorityToSso: BuildSettings.tchapFeatureHandleSSO) == kMXLoginFlowTypeSSO
}

// MARK: - Private
Expand Down
3 changes: 3 additions & 0 deletions Tchap/Config/BuildSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,9 @@ final class BuildSettings: NSObject {
]
]

// Tchap: handle SSO feature flag. Presents SSO button on Onboarding screen and give priority to SSO on UIA.
static let tchapFeatureHandleSSO = false

// MARK: - Side Menu
static let enableSideMenu: Bool = true && !newAppLayoutEnabled
static let sideMenuShowInviteFriends: Bool = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,28 +92,31 @@ struct TchapOnboardingSplashScreen: View {
HStack { // HStack to center horizontally
Spacer()
VStack {
// Button ProConnect
Button(action: { viewModel.send(viewAction: .login(.sso(ssoIdentityProviders: []))) }, label: {
HStack {
Image(uiImage: Asset_tchap.Images.proConnectIcon.image)
Text(LocalizedStringKey(TchapL10n.welcomeProConnectTitle)) // LocalizedStringKey is needed for markdown interpretation.
.fixedSize(horizontal: false, vertical: true) // .lineLimit(Int.max) doesn't work here.
.foregroundColor(.white)
}
.padding(EdgeInsets(top: 10.0, leading: 32.0, bottom: 10.0, trailing: 32.0))
})
.background(
Color(UIColor(rgb: 0x000091)),
in: RoundedRectangle(cornerRadius: 12.0)
)
.padding(.bottom, 8.0)

// Button "What is ProConnect?"
Button(action: { openProConnectWebsite() }, label: {
Text(TchapL10n.welcomeProConnectInfo)
})
.padding(.bottom, 32.0)
// Display ProConnect option only if enabled by feature flag.
if BuildSettings.tchapFeatureHandleSSO {
// Button ProConnect
Button(action: { viewModel.send(viewAction: .login(.sso(ssoIdentityProviders: []))) }, label: {
HStack {
Image(uiImage: Asset_tchap.Images.proConnectIcon.image)
Text(LocalizedStringKey(TchapL10n.welcomeProConnectTitle)) // LocalizedStringKey is needed for markdown interpretation.
.fixedSize(horizontal: false, vertical: true) // .lineLimit(Int.max) doesn't work here.
.foregroundColor(.white)
}
.padding(EdgeInsets(top: 10.0, leading: 32.0, bottom: 10.0, trailing: 32.0))
})
.background(
Color(UIColor(rgb: 0x000091)),
in: RoundedRectangle(cornerRadius: 12.0)
)
.padding(.bottom, 8.0)

// Button "What is ProConnect?"
Button(action: { openProConnectWebsite() }, label: {
Text(TchapL10n.welcomeProConnectInfo)
})
.padding(.bottom, 32.0)
}

/// Button "Connect with password"
Button(action: { viewModel.send(viewAction: .login(.password)) }, label: {
Text(TchapL10n.welcomePasswordTitle)
Expand Down
1 change: 1 addition & 0 deletions changelog.d/1110.change
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Activation de la gestion de ProConnect (login et UIA) via feature flag.
Loading