From 7f520507a042799bc1f6ce507b35bb7fa5edd123 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20B=C3=B6hlke?= Date: Wed, 9 Oct 2024 15:08:05 +0200 Subject: [PATCH] Use client login mask as keycloak login theme --- .../openslides-main/keycloak-login.ts | 14 +++ .../openslides-main.component.ts | 10 ++- .../account-button.component.ts | 1 + .../site/pages/login/login-routing.module.ts | 8 ++ .../login-mask/login-mask.component.html | 22 +++-- .../login-mask/login-mask.component.ts | 86 +++++++++++++++---- .../pages/login-mask/login-mask.module.ts | 5 +- client/src/app/site/services/auth.service.ts | 1 + .../services/openslides-router.service.ts | 1 + .../app/site/services/openslides.service.ts | 4 - client/src/app/site/site-routing.module.ts | 2 +- 11 files changed, 117 insertions(+), 37 deletions(-) create mode 100644 client/src/app/openslides-main-module/components/openslides-main/keycloak-login.ts diff --git a/client/src/app/openslides-main-module/components/openslides-main/keycloak-login.ts b/client/src/app/openslides-main-module/components/openslides-main/keycloak-login.ts new file mode 100644 index 0000000000..e5c7ab29a1 --- /dev/null +++ b/client/src/app/openslides-main-module/components/openslides-main/keycloak-login.ts @@ -0,0 +1,14 @@ +export type KeycloakLoginConfig = { + bootAsKeycloakPage: boolean; + jumpToRoute: string; + loginAction: string; + fieldErrors: { + password: string; + username: string; + }; +}; + +export function getKeycloakLoginConfig(): KeycloakLoginConfig { + // @ts-expect-error bootAsKeycloakPage is a global variable + return window.keycloakLoginConfig ? (window.keycloakLoginConfig as KeycloakLoginConfig) : null; +} diff --git a/client/src/app/openslides-main-module/components/openslides-main/openslides-main.component.ts b/client/src/app/openslides-main-module/components/openslides-main/openslides-main.component.ts index d4217ada8b..338959031e 100644 --- a/client/src/app/openslides-main-module/components/openslides-main/openslides-main.component.ts +++ b/client/src/app/openslides-main-module/components/openslides-main/openslides-main.component.ts @@ -19,8 +19,14 @@ import { OpenSlidesService } from 'src/app/site/services/openslides.service'; import { OpenSlidesStatusService } from 'src/app/site/services/openslides-status.service'; import { ViewModelStoreService } from 'src/app/site/services/view-model-store.service'; +import { getKeycloakLoginConfig } from './keycloak-login'; + const CURRENT_LANGUAGE_STORAGE_KEY = `currentLanguage`; +function bootAsKeycloakPage(): boolean { + return getKeycloakLoginConfig()?.bootAsKeycloakPage || false; +} + @Component({ selector: `os-root`, templateUrl: `./openslides-main.component.html`, @@ -47,7 +53,9 @@ export class OpenSlidesMainComponent implements OnInit { private modelStore: ViewModelStoreService, private authService: AuthService ) { - authService.startOidcWorkflow(); + if (!bootAsKeycloakPage()) { + authService.startOidcWorkflow(); + } overloadJsFunctions(); this.addDebugFunctions(); diff --git a/client/src/app/site/modules/global-headbar/components/account-button/account-button.component.ts b/client/src/app/site/modules/global-headbar/components/account-button/account-button.component.ts index caf54e5f22..79c5bb5919 100644 --- a/client/src/app/site/modules/global-headbar/components/account-button/account-button.component.ts +++ b/client/src/app/site/modules/global-headbar/components/account-button/account-button.component.ts @@ -135,6 +135,7 @@ export class AccountButtonComponent extends BaseUiComponent implements OnInit { } public async login(): Promise { + debugger; this.router.navigate([`/`, this.activeMeetingId, `login`]); } diff --git a/client/src/app/site/pages/login/login-routing.module.ts b/client/src/app/site/pages/login/login-routing.module.ts index 96857656a7..8c6da07303 100644 --- a/client/src/app/site/pages/login/login-routing.module.ts +++ b/client/src/app/site/pages/login/login-routing.module.ts @@ -8,6 +8,14 @@ const routes: Routes = [ path: ``, component: LoginWrapperComponent, children: [ + { + path: `realms/:realm/protocol/openid-connect/auth`, + loadChildren: () => import(`./pages/login-mask/login-mask.module`).then(m => m.LoginMaskModule) + }, + { + path: `realms/:realm/login-actions/authenticate`, + loadChildren: () => import(`./pages/login-mask/login-mask.module`).then(m => m.LoginMaskModule) + }, { path: `legalnotice`, loadChildren: () => import(`./pages/legal-notice/legal-notice.module`).then(m => m.LegalNoticeModule) diff --git a/client/src/app/site/pages/login/pages/login-mask/components/login-mask/login-mask.component.html b/client/src/app/site/pages/login/pages/login-mask/components/login-mask/login-mask.component.html index aa9f04cc68..a0a4c2bec8 100644 --- a/client/src/app/site/pages/login/pages/login-mask/components/login-mask/login-mask.component.html +++ b/client/src/app/site/pages/login/pages/login-mask/components/login-mask/login-mask.component.html @@ -29,18 +29,6 @@

} @if (samlEnabled && !loading) {