Skip to content

Commit 5ca89ce

Browse files
authored
Merge pull request #1111 from tchapgouv/386-sso-agentconnect-flow
feat(sso): add email domain precheck sso flow
2 parents 6db6eab + c42be00 commit 5ca89ce

File tree

25 files changed

+1179
-39
lines changed

25 files changed

+1179
-39
lines changed

config.dev.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,9 @@
125125
],
126126
"feature_screenshare_call": ["*"]
127127
},
128+
"tchap_sso_flow": {
129+
"isActive": true
130+
},
128131
"map_style_url": "https://openmaptiles.geo.data.gouv.fr/styles/osm-bright/style.json",
129132
"element_call": {
130133
"url": "https://element-call.tchap.incubateur.net/"

config.preprod.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,5 +111,8 @@
111111
"feature_video_call": ["i.tchap.gouv.fr", "e.tchap.gouv.fr"],
112112
"feature_screenshare_call": ["*"]
113113
},
114+
"tchap_sso_flow": {
115+
"isActive": false
116+
},
114117
"map_style_url": "https://openmaptiles.geo.data.gouv.fr/styles/osm-bright/style.json"
115118
}

config.prod.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,5 +198,8 @@
198198
"feature_video_call": ["agent.dinum.tchap.gouv.fr"],
199199
"feature_screenshare_call": ["*"]
200200
},
201+
"tchap_sso_flow": {
202+
"isActive": false
203+
},
201204
"map_style_url": "https://openmaptiles.geo.data.gouv.fr/styles/osm-bright/style.json"
202205
}

config.prod.lab.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,5 +198,8 @@
198198
"feature_video_call": ["agent.dinum.tchap.gouv.fr", "education.tchap.gouv.fr"],
199199
"feature_screenshare_call": ["*"]
200200
},
201+
"tchap_sso_flow": {
202+
"isActive": false
203+
},
201204
"map_style_url": "https://openmaptiles.geo.data.gouv.fr/styles/osm-bright/style.json"
202205
}

linked-dependencies/matrix-react-sdk/src/Views.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ enum Views {
5454

5555
// Another instance of the application has started up. We just show an error page.
5656
LOCK_STOLEN,
57+
58+
// :TCHAP: screen before launching sso
59+
EMAIL_PRECHECK_SSO
5760
}
5861

5962
export default Views;

linked-dependencies/matrix-react-sdk/src/components/structures/MatrixChat.tsx

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,11 @@ import { checkSessionLockFree, getSessionLock } from "../../utils/SessionLock";
143143
import { SessionLockStolenView } from "./auth/SessionLockStolenView";
144144
import { ConfirmSessionLockTheftView } from "./auth/ConfirmSessionLockTheftView";
145145
import { LoginSplashView } from "./auth/LoginSplashView";
146-
import TchapUrls from "../../../../../src/tchap/util/TchapUrls"; // :TCHAP: activate-cross-signing-and-secure-storage-react
147146
import { cleanUpDraftsIfRequired } from "../../DraftCleaner";
148147

148+
import TchapUrls from "../../../../../src/tchap/util/TchapUrls"; // :TCHAP: activate-cross-signing-and-secure-storage-react
149+
import EmailVerificationPage from "../../../../../src/tchap/components/views/sso/EmailVerificationPage"; // :TCHAP: sso-agentconnect-flow
150+
149151
// legacy export
150152
export { default as Views } from "../../Views";
151153

@@ -946,6 +948,15 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
946948
true,
947949
);
948950
break;
951+
// :TCHAP: sso-agentconnect-flow
952+
case Action.EmailPrecheckSSO:
953+
if (Lifecycle.isSoftLogout()) {
954+
this.onSoftLogout();
955+
break;
956+
}
957+
this.viewEmailPrecheckSSO();
958+
break;
959+
// end :TCHAP:
949960
}
950961
};
951962

@@ -1104,6 +1115,17 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
11041115
this.themeWatcher.recheck();
11051116
}
11061117

1118+
// :TCHAP: sso-agentconnect-flow
1119+
private viewEmailPrecheckSSO() {
1120+
this.setStateForNewView({
1121+
view: Views.EMAIL_PRECHECK_SSO
1122+
});
1123+
this.notifyNewScreen("email-precheck-sso");
1124+
ThemeController.isLogin = true;
1125+
this.themeWatcher.recheck();
1126+
}
1127+
// end :TCHAP:
1128+
11071129
private viewHome(justRegistered = false): void {
11081130
// The home page requires the "logged in" view, so we'll set that.
11091131
this.setStateForNewView({
@@ -1875,6 +1897,13 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
18751897
userId: userId,
18761898
subAction: params?.action,
18771899
});
1900+
// :TCHAP: sso-agentconnect-flow
1901+
} else if (screen = "email-precheck-sso") {
1902+
dis.dispatch({
1903+
action: "email_precheck_sso",
1904+
params
1905+
});
1906+
// end :TCHAP:
18781907
} else {
18791908
logger.info(`Ignoring showScreen for '${screen}'`);
18801909
}
@@ -2017,7 +2046,9 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
20172046
if (
20182047
initialScreenAfterLogin &&
20192048
// XXX: workaround for https://github.com/vector-im/element-web/issues/11643 causing a login-loop
2020-
!["welcome", "login", "register", "start_sso", "start_cas"].includes(initialScreenAfterLogin.screen)
2049+
// :TCHAP: sso-agentconnect-flow !["welcome", "login", "register", "start_sso", "start_cas"].includes(initialScreenAfterLogin.screen)
2050+
!["welcome", "login", "register", "start_sso", "start_cas", "email-precheck-sso"].includes(initialScreenAfterLogin.screen)
2051+
// end :TCHAP:
20212052
) {
20222053
fragmentAfterLogin = `/${initialScreenAfterLogin.screen}`;
20232054
}
@@ -2137,6 +2168,10 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
21372168
view = <UseCaseSelection onFinished={(useCase): Promise<void> => this.onShowPostLoginScreen(useCase)} />;
21382169
} else if (this.state.view === Views.LOCK_STOLEN) {
21392170
view = <SessionLockStolenView />;
2171+
// :TCHAP: sso-agentconnect-flow
2172+
} else if (this.state.view === Views.EMAIL_PRECHECK_SSO) {
2173+
view = <EmailVerificationPage />;
2174+
// end :TCHAP:
21402175
} else {
21412176
logger.error(`Unknown view ${this.state.view}`);
21422177
return null;

linked-dependencies/matrix-react-sdk/src/components/structures/auth/Login.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,8 @@ export default class LoginComponent extends React.PureComponent<IProps, IState>
138138
// eslint-disable-next-line @typescript-eslint/naming-convention
139139
"m.login.cas": () => this.renderSsoStep("cas"),
140140
// eslint-disable-next-line @typescript-eslint/naming-convention
141-
"m.login.sso": () => this.renderSsoStep("sso"),
141+
// :TCHAP: sso-agentconnect-flow
142+
// "m.login.sso": () => this.renderSsoStep("sso"),
142143
"oidcNativeFlow": () => this.renderOidcNativeStep(),
143144
};
144145
}

linked-dependencies/matrix-react-sdk/src/components/structures/auth/Registration.tsx

Lines changed: 42 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ import { Features } from "../../../settings/Settings";
5757
import { startOidcLogin } from "../../../utils/oidc/authorize";
5858

5959
import TchapUtils from '../../../../../../src/tchap/util/TchapUtils'; // :TCHAP: registration-for-mainlining
60-
import TchapUrls from "../../../../../../src/tchap/util/TchapUrls";
60+
import TchapUIFeature from "../../../../../../src/tchap/util/TchapUIFeature"; // :TCHAP: sso-agentconnect-flow
61+
import ProconnectButton from "../../../../../../src/tchap/components/views/sso/ProconnectButton"; // :TCHAP: sso-agentconnect-flow
6162

6263
const debuglog = (...args: any[]): void => {
6364
if (SettingsStore.getValue("debug_registration")) {
@@ -592,39 +593,47 @@ export default class Registration extends React.Component<IProps, IState> {
592593
);
593594
} else if (this.state.matrixClient && this.state.flows.length) {
594595
let ssoSection: JSX.Element | undefined;
595-
if (this.state.ssoFlow) {
596-
let continueWithSection;
597-
const providers = this.state.ssoFlow.identity_providers || [];
598-
// when there is only a single (or 0) providers we show a wide button with `Continue with X` text
599-
if (providers.length > 1) {
600-
// i18n: ssoButtons is a placeholder to help translators understand context
601-
continueWithSection = (
602-
<h2 className="mx_AuthBody_centered">
603-
{_t("auth|continue_with_sso", { ssoButtons: "" }).trim()}
604-
</h2>
605-
);
606-
}
607-
608-
// i18n: ssoButtons & usernamePassword are placeholders to help translators understand context
609-
ssoSection = (
610-
<React.Fragment>
611-
{continueWithSection}
612-
<SSOButtons
613-
matrixClient={this.loginLogic.createTemporaryClient()}
614-
flow={this.state.ssoFlow}
615-
loginType={this.state.ssoFlow.type === "m.login.sso" ? "sso" : "cas"}
616-
fragmentAfterLogin={this.props.fragmentAfterLogin}
617-
action={SSOAction.REGISTER}
618-
/>
619-
<h2 className="mx_AuthBody_centered">
620-
{_t("auth|sso_or_username_password", {
621-
ssoButtons: "",
622-
usernamePassword: "",
623-
}).trim()}
624-
</h2>
625-
</React.Fragment>
626-
);
596+
// :TCHAP: sso-agentconnect-flow
597+
// if (this.state.ssoFlow) {
598+
// let continueWithSection;
599+
// const providers = this.state.ssoFlow.identity_providers || [];
600+
// // when there is only a single (or 0) providers we show a wide button with `Continue with X` text
601+
// if (providers.length > 1) {
602+
// // i18n: ssoButtons is a placeholder to help translators understand context
603+
// continueWithSection = (
604+
// <h2 className="mx_AuthBody_centered">
605+
// {_t("auth|continue_with_sso", { ssoButtons: "" }).trim()}
606+
// </h2>
607+
// );
608+
// }
609+
610+
// // i18n: ssoButtons & usernamePassword are placeholders to help translators understand context
611+
// ssoSection = (
612+
// <React.Fragment>
613+
// {continueWithSection}
614+
// <SSOButtons
615+
// matrixClient={this.loginLogic.createTemporaryClient()}
616+
// flow={this.state.ssoFlow}
617+
// loginType={this.state.ssoFlow.type === "m.login.sso" ? "sso" : "cas"}
618+
// fragmentAfterLogin={this.props.fragmentAfterLogin}
619+
// action={SSOAction.REGISTER}
620+
// />
621+
// <h2 className="mx_AuthBody_centered">
622+
// {_t("auth|sso_or_username_password", {
623+
// ssoButtons: "",
624+
// usernamePassword: "",
625+
// }).trim()}
626+
// </h2>
627+
// </React.Fragment>
628+
// );
629+
if (this.state.ssoFlow && TchapUIFeature.isSSOFlowActive()) {
630+
ssoSection = <>
631+
<ProconnectButton/>
632+
<p style={{textAlign: "center", fontWeight: "bold"}}>{_t("auth|sso|or")}</p>
633+
</>
627634
}
635+
// }
636+
// end :TCHAP:
628637

629638
return (
630639
<React.Fragment>

linked-dependencies/matrix-react-sdk/src/components/views/auth/Welcome.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import { UIFeature } from "../../../settings/UIFeature";
2424
import LanguageSelector from "./LanguageSelector";
2525
import EmbeddedPage from "../../structures/EmbeddedPage";
2626
import { MATRIX_LOGO_HTML } from "../../structures/static-page-vars";
27+
import TchapUIFeature from "../../../../../../src/tchap/util/TchapUIFeature";
2728

2829
interface IProps {}
2930

@@ -47,7 +48,9 @@ export default class Welcome extends React.PureComponent<IProps> {
4748
const brandingConfig = SdkConfig.getObject("branding");
4849
const logoUrl = brandingConfig?.get("auth_header_logo_url") ?? "themes/element/img/logos/element-logo.svg";
4950
replaceMap["$logoUrl"] = logoUrl;
50-
pageUrl = "welcome.html";
51+
// :TCHAP: sso-agentconnect-flow - pageUrl = "welcome.html";
52+
pageUrl = TchapUIFeature.isSSOFlowActive() ? "welcome_sso.html" : "welcome.html";
53+
// end :TCHAP:
5154
}
5255

5356
return (

linked-dependencies/matrix-react-sdk/src/dispatcher/actions.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,4 +393,9 @@ export enum Action {
393393
* Opens right panel room summary and focuses the search input
394394
*/
395395
FocusMessageSearch = "focus_search",
396+
397+
/**
398+
* :TCHAP: Open new page to check email instance before launching SSO
399+
*/
400+
EmailPrecheckSSO = "email_precheck_sso"
396401
}

modules/tchap-translations/tchap_translations.json

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -837,5 +837,41 @@
837837
"incompatible_browser|continue": {
838838
"en": "Continue anyway",
839839
"fr": "Continuer tout de même"
840+
},
841+
"auth|sso|sign_in_password_instead": {
842+
"en": "Login with password",
843+
"fr": "Se connecter par mot de passe"
844+
},
845+
"auth|sso|email_title": {
846+
"en": "Login with ProConnect",
847+
"fr": "Se connecter avec ProConnect"
848+
},
849+
"auth|sso|proconnect_continue": {
850+
"en": "Continue with ProConnect",
851+
"fr": "Continuer avec ProConnect"
852+
},
853+
"auth|sso|email_placeholder": {
854+
"en": "Your professional email",
855+
"fr": "Votre adresse mail professionelle"
856+
},
857+
"welcome|sso|proconnect_explanation": {
858+
"en": "-> What is ProConnect ?",
859+
"fr": "-> Qu'est-ce que ProConnect ?"
860+
},
861+
"auth|sso|error": {
862+
"en": "An error occured during SSO login",
863+
"fr": "Une erreur est survenue lors de la connexion"
864+
},
865+
"auth|sso|error_homeserver": {
866+
"en": "There is an error with the homeserver configuration",
867+
"fr": "Il y a une erreur avec la configuration du serveur"
868+
},
869+
"auth|sso|error_email": {
870+
"en": "You need to enter your professional email",
871+
"fr": "Vous devez entrer votre adresse professionelle"
872+
},
873+
"auth|sso|or": {
874+
"en": "or",
875+
"fr": "ou"
840876
}
841877
}

modules/tchap-translations/tchap_translations_removed.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,6 @@
5555
"create_space|public_heading",
5656
"common|private",
5757
"room_list|add_space_label",
58-
"spaces|error_no_permission_add_space"
58+
"spaces|error_no_permission_add_space",
59+
"auth|continue_with_sso"
5960
]

patches/subtree-modifications.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,5 +78,14 @@
7878
"files": [
7979
"src/components/views/settings/tabs/user/AccountUserSettingsTab.tsx"
8080
]
81+
},
82+
"sso-agentconnect-flow": {
83+
"issue": "https://github.com/tchapgouv/tchap-web-v4/issues/386",
84+
"files": [
85+
"src/components/structures/MatrixChat.tsx",
86+
"src/components/structures/auth/Registration.tsx",
87+
"src/components/structures/auth/Login.tsx",
88+
"src/components/views/auth/Welcome.tsx"
89+
]
8190
}
8291
}

res/css/views/sso/TchapSSO.pcss

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
.tc_pronnect {
2+
.tc_ButtonParent {
3+
display: -webkit-box;
4+
display: -webkit-flex;
5+
display: -ms-flexbox;
6+
display: flex;
7+
padding: 14px 20px;
8+
-webkit-box-orient: horizontal;
9+
-webkit-box-direction: normal;
10+
-webkit-flex-direction: row;
11+
-ms-flex-direction: row;
12+
flex-direction: row;
13+
-webkit-box-pack: center;
14+
-webkit-justify-content: center;
15+
-ms-flex-pack: center;
16+
justify-content: center;
17+
-webkit-box-align: center;
18+
-webkit-align-items: center;
19+
-ms-flex-align: center;
20+
align-items: center;
21+
border-radius: 4px;
22+
background-origin: content-box;
23+
background-repeat: no-repeat;
24+
background-position: 30px center;
25+
text-decoration: none;
26+
color: #2e2f32 !important;
27+
}
28+
29+
.tc_ButtonProconnect {
30+
background-color: var(--accent);
31+
color: white !important;
32+
}
33+
34+
.tc_Button_iconPC {
35+
background-image: url("../../../welcome/images/proconnect.svg");
36+
}
37+
38+
.tc_bottomButton {
39+
display: flex;
40+
justify-content: center;
41+
}
42+
43+
.tc_login {
44+
.tc_ButtonParent {
45+
width: 100%;
46+
}
47+
48+
.tc_ButtonProconnect {
49+
margin-bottom: 40px;
50+
}
51+
}
52+
}

0 commit comments

Comments
 (0)