From 4befb779f8f35ade3d6fc662befc3dc8e6d2e4e0 Mon Sep 17 00:00:00 2001 From: Dharan <14145706+dhrn@users.noreply.github.com> Date: Mon, 2 Aug 2021 15:00:09 +0530 Subject: [PATCH] [MNT-22334] ADW - User information not displayed when Kerberos is in use (#7172) * [MNT-22334] ADW - User information not displayed when Kerberos is in use * * enable kerberos * * added test * Revert "* enable kerberos" --- lib/core/services/authentication.service.spec.ts | 11 +++++++++++ lib/core/services/authentication.service.ts | 12 ++++++++++++ 2 files changed, 23 insertions(+) diff --git a/lib/core/services/authentication.service.spec.ts b/lib/core/services/authentication.service.spec.ts index f400314d9e5..1bcb2c14f89 100644 --- a/lib/core/services/authentication.service.spec.ts +++ b/lib/core/services/authentication.service.spec.ts @@ -65,6 +65,7 @@ describe('AuthenticationService', () => { beforeEach(() => { appConfigService.config.providers = 'ECM'; + appConfigService.config.auth = { withCredentials: false }; appConfigService.load(); apiService.reset(); }); @@ -186,12 +187,20 @@ describe('AuthenticationService', () => { it('[ECM] should return isBpmLoggedIn false', () => { expect(authService.isBpmLoggedIn()).toBe(false); }); + + it('[ECM] should return true if kerberos configured', () => { + appConfigService.config.auth.withCredentials = true ; + + expect(authService.isLoggedInWith('ECM')).toBe(true); + expect(authService.isLoggedIn()).toBe(true); + }); }); describe('when the setting is BPM', () => { beforeEach(() => { appConfigService.config.providers = 'BPM'; + appConfigService.config.auth = { withCredentials: false }; appConfigService.load(); apiService.reset(); }); @@ -321,6 +330,7 @@ describe('AuthenticationService', () => { beforeEach(() => { appConfigService.config.providers = 'ECM'; + appConfigService.config.auth = { withCredentials: false }; appConfigService.load(); apiService.reset(); }); @@ -385,6 +395,7 @@ describe('AuthenticationService', () => { beforeEach(() => { appConfigService.config.providers = 'ALL'; + appConfigService.config.auth = { withCredentials: false }; appConfigService.load(); apiService.reset(); }); diff --git a/lib/core/services/authentication.service.ts b/lib/core/services/authentication.service.ts index c6a1f5a3b67..da9fe9c9294 100644 --- a/lib/core/services/authentication.service.ts +++ b/lib/core/services/authentication.service.ts @@ -64,6 +64,10 @@ export class AuthenticationService { * @returns True if logged in, false otherwise */ isLoggedIn(): boolean { + if (this.isKerberosConfigured()) { + return true; + } + if (!this.isOauth() && this.cookie.isEnabled() && !this.isRememberMeSet()) { return false; } @@ -224,6 +228,10 @@ export class AuthenticationService { * @returns True if logged in, false otherwise */ isEcmLoggedIn(): boolean { + if (this.isKerberosConfigured()) { + return true; + } + if (this.isECMProvider() || this.isALLProvider()) { if (!this.isOauth() && this.cookie.isEnabled() && !this.isRememberMeSet()) { return false; @@ -247,6 +255,10 @@ export class AuthenticationService { return false; } + isKerberosConfigured(): boolean { + return this.appConfig.get(AppConfigValues.AUTH_WITH_CREDENTIALS, false); + } + /** * Gets the ECM username. * @returns The ECM username