From 26be911753dfbc033d63207295ad8a769c56120b Mon Sep 17 00:00:00 2001 From: Eugenio Romano Date: Wed, 4 Dec 2019 19:36:18 +0000 Subject: [PATCH 1/7] close all the dialogs after false canActivate event --- lib/core/services/auth-guard-base.ts | 12 ++++++++++-- .../services/auth-guard-bpm.service.spec.ts | 18 ++++++++++++++++++ lib/core/services/auth-guard-bpm.service.ts | 7 +++++-- .../services/auth-guard-ecm.service.spec.ts | 19 +++++++++++++++++++ lib/core/services/auth-guard-ecm.service.ts | 6 ++++-- .../auth-guard-sso-role.service.spec.ts | 17 +++++++++++++++++ lib/core/services/auth-guard.service.ts | 6 ++++-- 7 files changed, 77 insertions(+), 8 deletions(-) diff --git a/lib/core/services/auth-guard-base.ts b/lib/core/services/auth-guard-base.ts index e165371ac2..2e133b13bd 100644 --- a/lib/core/services/auth-guard-base.ts +++ b/lib/core/services/auth-guard-base.ts @@ -29,6 +29,7 @@ import { AppConfigValues } from '../app-config/app-config.service'; import { OauthConfigModel } from '../models/oauth-config.model'; +import { MatDialog } from '@angular/material'; export abstract class AuthGuardBase implements CanActivate, CanActivateChild { abstract checkLogin( @@ -46,14 +47,21 @@ export abstract class AuthGuardBase implements CanActivate, CanActivateChild { constructor( protected authenticationService: AuthenticationService, protected router: Router, - protected appConfigService: AppConfigService + protected appConfigService: AppConfigService, + protected dialog: MatDialog ) {} canActivate( route: ActivatedRouteSnapshot, state: RouterStateSnapshot ): Observable | Promise | boolean { - return this.checkLogin(route, state.url); + const checkLogin = this.checkLogin(route, state.url); + + if (!checkLogin) { + this.dialog.closeAll(); + } + + return checkLogin; } canActivateChild( diff --git a/lib/core/services/auth-guard-bpm.service.spec.ts b/lib/core/services/auth-guard-bpm.service.spec.ts index 0adc45fadc..a8148f0b4a 100644 --- a/lib/core/services/auth-guard-bpm.service.spec.ts +++ b/lib/core/services/auth-guard-bpm.service.spec.ts @@ -22,6 +22,7 @@ import { AuthenticationService } from './authentication.service'; import { RouterStateSnapshot, Router } from '@angular/router'; import { setupTestBed } from '../testing/setupTestBed'; import { CoreTestingModule } from '../testing/core.testing.module'; +import { MatDialog } from '@angular/material'; describe('AuthGuardService BPM', () => { @@ -156,4 +157,21 @@ describe('AuthGuardService BPM', () => { expect(router.navigateByUrl).toHaveBeenCalledWith('/fakeLoginRoute?redirectUrl=some-url'); })); + it('should to close the material dialog if is redirect to the login', () => { + const materialDialog = TestBed.get(MatDialog); + + spyOn(materialDialog, 'closeAll'); + + spyOn(authService, 'setRedirect').and.callThrough(); + spyOn(router, 'navigateByUrl').and.stub(); + const route: RouterStateSnapshot = { url: 'some-url' }; + + authGuard.canActivate(null, route); + + expect(authService.setRedirect).toHaveBeenCalledWith({ + provider: 'ECM', url: 'some-url' + }); + + expect(materialDialog.closeAll).toHaveBeenCalled(); + }); }); diff --git a/lib/core/services/auth-guard-bpm.service.ts b/lib/core/services/auth-guard-bpm.service.ts index eba0ab4a26..2e2a67ec53 100644 --- a/lib/core/services/auth-guard-bpm.service.ts +++ b/lib/core/services/auth-guard-bpm.service.ts @@ -21,6 +21,7 @@ import { AppConfigService } from '../app-config/app-config.service'; import { AuthenticationService } from './authentication.service'; import { AuthGuardBase } from './auth-guard-base'; import { Observable } from 'rxjs'; +import { MatDialog } from '@angular/material'; @Injectable({ providedIn: 'root' @@ -29,8 +30,10 @@ export class AuthGuardBpm extends AuthGuardBase { constructor(authenticationService: AuthenticationService, router: Router, - appConfigService: AppConfigService) { - super(authenticationService, router, appConfigService); + appConfigService: AppConfigService, + dialog: MatDialog + ) { + super(authenticationService, router, appConfigService, dialog); } checkLogin(_: ActivatedRouteSnapshot, redirectUrl: string): Observable | Promise | boolean { diff --git a/lib/core/services/auth-guard-ecm.service.spec.ts b/lib/core/services/auth-guard-ecm.service.spec.ts index 611d14d83a..20549d9730 100644 --- a/lib/core/services/auth-guard-ecm.service.spec.ts +++ b/lib/core/services/auth-guard-ecm.service.spec.ts @@ -22,6 +22,7 @@ import { AuthenticationService } from './authentication.service'; import { RouterStateSnapshot, Router } from '@angular/router'; import { setupTestBed } from '../testing/setupTestBed'; import { CoreTestingModule } from '../testing/core.testing.module'; +import { MatDialog } from '@angular/material'; describe('AuthGuardService ECM', () => { @@ -156,4 +157,22 @@ describe('AuthGuardService ECM', () => { expect(router.navigateByUrl).toHaveBeenCalledWith('/fakeLoginRoute?redirectUrl=some-url'); })); + it('should to close the material dialog if is redirect to the login', () => { + const materialDialog = TestBed.get(MatDialog); + + spyOn(materialDialog, 'closeAll'); + + spyOn(authService, 'setRedirect').and.callThrough(); + spyOn(router, 'navigateByUrl').and.stub(); + const route: RouterStateSnapshot = { url: 'some-url' }; + + authGuard.canActivate(null, route); + + expect(authService.setRedirect).toHaveBeenCalledWith({ + provider: 'ECM', url: 'some-url' + }); + + expect(materialDialog.closeAll).toHaveBeenCalled(); + }); + }); diff --git a/lib/core/services/auth-guard-ecm.service.ts b/lib/core/services/auth-guard-ecm.service.ts index 57292538fa..2a459e7cd2 100644 --- a/lib/core/services/auth-guard-ecm.service.ts +++ b/lib/core/services/auth-guard-ecm.service.ts @@ -23,6 +23,7 @@ import { AuthenticationService } from './authentication.service'; import { AppConfigService } from '../app-config/app-config.service'; import { AuthGuardBase } from './auth-guard-base'; import { Observable } from 'rxjs'; +import { MatDialog } from '@angular/material'; @Injectable({ providedIn: 'root' @@ -31,8 +32,9 @@ export class AuthGuardEcm extends AuthGuardBase { constructor(authenticationService: AuthenticationService, router: Router, - appConfigService: AppConfigService) { - super(authenticationService, router, appConfigService); + appConfigService: AppConfigService, + dialog: MatDialog) { + super(authenticationService, router, appConfigService, dialog); } checkLogin(_: ActivatedRouteSnapshot, redirectUrl: string): Observable | Promise | boolean { diff --git a/lib/core/services/auth-guard-sso-role.service.spec.ts b/lib/core/services/auth-guard-sso-role.service.spec.ts index 9b80836547..ceda5fb80f 100644 --- a/lib/core/services/auth-guard-sso-role.service.spec.ts +++ b/lib/core/services/auth-guard-sso-role.service.spec.ts @@ -21,6 +21,7 @@ import { setupTestBed } from '../testing/setupTestBed'; import { CoreTestingModule } from '../testing/core.testing.module'; import { AuthGuardSsoRoleService } from './auth-guard-sso-role.service'; import { JwtHelperService } from './jwt-helper.service'; +import { MatDialog } from '@angular/material'; describe('Auth Guard SSO role service', () => { @@ -164,4 +165,20 @@ describe('Auth Guard SSO role service', () => { expect(authGuard.canActivate(route)).toBeFalsy(); }); + + it('Should canActivate be false hasRealm is true and hasClientRole is false', () => { + const materialDialog = TestBed.get(MatDialog); + + spyOn(materialDialog, 'closeAll'); + + const route: ActivatedRouteSnapshot = new ActivatedRouteSnapshot(); + spyOn(jwtHelperService, 'hasRealmRoles').and.returnValue(true); + spyOn(jwtHelperService, 'hasRealmRolesForClientRole').and.returnValue(false); + + route.params = { appName: 'fakeapp' }; + route.data = { 'clientRoles': ['appName'], 'roles': ['role1', 'role2'] }; + + expect(materialDialog.closeAll).toHaveBeenCalled(); + }); + }); diff --git a/lib/core/services/auth-guard.service.ts b/lib/core/services/auth-guard.service.ts index 5d9aa4d31e..bbe9b2fbb8 100644 --- a/lib/core/services/auth-guard.service.ts +++ b/lib/core/services/auth-guard.service.ts @@ -22,6 +22,7 @@ import { Observable } from 'rxjs'; import { AppConfigService } from '../app-config/app-config.service'; import { AuthGuardBase } from './auth-guard-base'; import { JwtHelperService } from './jwt-helper.service'; +import { MatDialog } from '@angular/material'; @Injectable({ providedIn: 'root' @@ -33,8 +34,9 @@ export class AuthGuard extends AuthGuardBase { constructor(private jwtHelperService: JwtHelperService, authenticationService: AuthenticationService, router: Router, - appConfigService: AppConfigService) { - super(authenticationService, router, appConfigService); + appConfigService: AppConfigService, + dialog: MatDialog) { + super(authenticationService, router, appConfigService, dialog); this.ticketChangeBind = this.ticketChange.bind(this); window.addEventListener('storage', this.ticketChangeBind); From ffef29fd779466b52856e682ad4409ddb61cfc6a Mon Sep 17 00:00:00 2001 From: Eugenio Romano Date: Wed, 4 Dec 2019 23:07:48 +0000 Subject: [PATCH 2/7] Update auth-guard-bpm.service.spec.ts --- lib/core/services/auth-guard-bpm.service.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/core/services/auth-guard-bpm.service.spec.ts b/lib/core/services/auth-guard-bpm.service.spec.ts index a8148f0b4a..88161cfbad 100644 --- a/lib/core/services/auth-guard-bpm.service.spec.ts +++ b/lib/core/services/auth-guard-bpm.service.spec.ts @@ -169,7 +169,7 @@ describe('AuthGuardService BPM', () => { authGuard.canActivate(null, route); expect(authService.setRedirect).toHaveBeenCalledWith({ - provider: 'ECM', url: 'some-url' + provider: 'BPM', url: 'some-url' }); expect(materialDialog.closeAll).toHaveBeenCalled(); From 0c9726049a80ff983b713e37b8a66a8f3572e754 Mon Sep 17 00:00:00 2001 From: Eugenio Romano Date: Tue, 17 Dec 2019 17:13:03 +0000 Subject: [PATCH 3/7] fix usage of prefix and remove localstorage use in favour of our internal service --- lib/core/services/alfresco-api.service.ts | 1 + lib/core/services/auth-guard.service.ts | 6 +++--- lib/core/services/authentication.service.ts | 4 +++- lib/core/services/jwt-helper.service.ts | 7 ++++--- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/lib/core/services/alfresco-api.service.ts b/lib/core/services/alfresco-api.service.ts index adc5d7fe69..c0ec11fdc7 100644 --- a/lib/core/services/alfresco-api.service.ts +++ b/lib/core/services/alfresco-api.service.ts @@ -134,6 +134,7 @@ export class AlfrescoApiService { contextRoot: this.appConfig.get(AppConfigValues.CONTEXTROOTECM), disableCsrf: this.appConfig.get(AppConfigValues.DISABLECSRF), withCredentials: this.appConfig.get(AppConfigValues.AUTH_WITH_CREDENTIALS, false), + domainPrefix : this.appConfig.get(AppConfigValues.STORAGE_PREFIX), oauth2: oauth }); diff --git a/lib/core/services/auth-guard.service.ts b/lib/core/services/auth-guard.service.ts index bbe9b2fbb8..2fe90b31b0 100644 --- a/lib/core/services/auth-guard.service.ts +++ b/lib/core/services/auth-guard.service.ts @@ -43,15 +43,15 @@ export class AuthGuard extends AuthGuardBase { } ticketChange(event: StorageEvent) { - if (event.key === 'ticket-ECM' && event.newValue !== event.oldValue) { + if (event.key.includes('ticket-ECM') && event.newValue !== event.oldValue) { this.ticketChangeRedirect(event, 'ECM'); } - if (event.key === 'ticket-BPM' && event.newValue !== event.oldValue) { + if (event.key.includes('ticket-BPM') && event.newValue !== event.oldValue) { this.ticketChangeRedirect(event, 'BPM'); } - if (event.key === JwtHelperService.USER_ACCESS_TOKEN && + if (event.key.includes(JwtHelperService.USER_ACCESS_TOKEN) && this.jwtHelperService.getValueFromToken(event.newValue, JwtHelperService.USER_PREFERRED_USERNAME) !== this.jwtHelperService.getValueFromToken(event.oldValue, JwtHelperService.USER_PREFERRED_USERNAME)) { this.ticketChangeRedirect(event, 'ALL'); diff --git a/lib/core/services/authentication.service.ts b/lib/core/services/authentication.service.ts index 31ac5304ee..7c5cdf4dae 100644 --- a/lib/core/services/authentication.service.ts +++ b/lib/core/services/authentication.service.ts @@ -26,6 +26,7 @@ import { UserRepresentation } from '@alfresco/js-api'; import { map, catchError, tap } from 'rxjs/operators'; import { HttpHeaders } from '@angular/common/http'; import { JwtHelperService } from './jwt-helper.service'; +import { StorageService } from './storage.service'; const REMEMBER_ME_COOKIE_KEY = 'ALFRESCO_REMEMBER_ME'; const REMEMBER_ME_UNTIL = 1000 * 60 * 60 * 24 * 30; @@ -43,6 +44,7 @@ export class AuthenticationService { constructor( private appConfig: AppConfigService, + private storageService: StorageService, private alfrescoApi: AlfrescoApiService, private cookie: CookieService, private logService: LogService) { @@ -292,7 +294,7 @@ export class AuthenticationService { * @returns Auth token string */ getToken(): string { - return localStorage.getItem(JwtHelperService.USER_ACCESS_TOKEN); + return this.storageService.getItem(JwtHelperService.USER_ACCESS_TOKEN); } /** diff --git a/lib/core/services/jwt-helper.service.ts b/lib/core/services/jwt-helper.service.ts index 667780323d..4f9cca7f42 100644 --- a/lib/core/services/jwt-helper.service.ts +++ b/lib/core/services/jwt-helper.service.ts @@ -16,6 +16,7 @@ */ import { Injectable } from '@angular/core'; +import { StorageService } from './storage.service'; @Injectable({ providedIn: 'root' @@ -31,7 +32,7 @@ export class JwtHelperService { static RESOURCE_ACCESS = 'resource_access'; static USER_PREFERRED_USERNAME = 'preferred_username'; - constructor() { + constructor(private storageService: StorageService) { } /** @@ -89,12 +90,12 @@ export class JwtHelperService { * @returns access token */ getAccessToken(): string { - return localStorage.getItem(JwtHelperService.USER_ACCESS_TOKEN); + return this.storageService.getItem(JwtHelperService.USER_ACCESS_TOKEN); } /** * Gets a named value from the user access token. - * @param key accessToken + * @param accessToken your SSO access token where the value is encode * @param key Key name of the field to retrieve * @returns Value from the token */ From aba7095d3d53fc17be2cc82216cb0f09d4be702b Mon Sep 17 00:00:00 2001 From: Eugenio Romano Date: Tue, 17 Dec 2019 17:16:49 +0000 Subject: [PATCH 4/7] remove other PR code --- lib/core/services/auth-guard-base.ts | 12 ++---------- .../services/auth-guard-bpm.service.spec.ts | 18 ------------------ lib/core/services/auth-guard-bpm.service.ts | 7 ++----- .../services/auth-guard-ecm.service.spec.ts | 19 ------------------- lib/core/services/auth-guard-ecm.service.ts | 6 ++---- .../auth-guard-sso-role.service.spec.ts | 17 ----------------- lib/core/services/auth-guard.service.ts | 6 ++---- 7 files changed, 8 insertions(+), 77 deletions(-) diff --git a/lib/core/services/auth-guard-base.ts b/lib/core/services/auth-guard-base.ts index 2e133b13bd..e165371ac2 100644 --- a/lib/core/services/auth-guard-base.ts +++ b/lib/core/services/auth-guard-base.ts @@ -29,7 +29,6 @@ import { AppConfigValues } from '../app-config/app-config.service'; import { OauthConfigModel } from '../models/oauth-config.model'; -import { MatDialog } from '@angular/material'; export abstract class AuthGuardBase implements CanActivate, CanActivateChild { abstract checkLogin( @@ -47,21 +46,14 @@ export abstract class AuthGuardBase implements CanActivate, CanActivateChild { constructor( protected authenticationService: AuthenticationService, protected router: Router, - protected appConfigService: AppConfigService, - protected dialog: MatDialog + protected appConfigService: AppConfigService ) {} canActivate( route: ActivatedRouteSnapshot, state: RouterStateSnapshot ): Observable | Promise | boolean { - const checkLogin = this.checkLogin(route, state.url); - - if (!checkLogin) { - this.dialog.closeAll(); - } - - return checkLogin; + return this.checkLogin(route, state.url); } canActivateChild( diff --git a/lib/core/services/auth-guard-bpm.service.spec.ts b/lib/core/services/auth-guard-bpm.service.spec.ts index 88161cfbad..0adc45fadc 100644 --- a/lib/core/services/auth-guard-bpm.service.spec.ts +++ b/lib/core/services/auth-guard-bpm.service.spec.ts @@ -22,7 +22,6 @@ import { AuthenticationService } from './authentication.service'; import { RouterStateSnapshot, Router } from '@angular/router'; import { setupTestBed } from '../testing/setupTestBed'; import { CoreTestingModule } from '../testing/core.testing.module'; -import { MatDialog } from '@angular/material'; describe('AuthGuardService BPM', () => { @@ -157,21 +156,4 @@ describe('AuthGuardService BPM', () => { expect(router.navigateByUrl).toHaveBeenCalledWith('/fakeLoginRoute?redirectUrl=some-url'); })); - it('should to close the material dialog if is redirect to the login', () => { - const materialDialog = TestBed.get(MatDialog); - - spyOn(materialDialog, 'closeAll'); - - spyOn(authService, 'setRedirect').and.callThrough(); - spyOn(router, 'navigateByUrl').and.stub(); - const route: RouterStateSnapshot = { url: 'some-url' }; - - authGuard.canActivate(null, route); - - expect(authService.setRedirect).toHaveBeenCalledWith({ - provider: 'BPM', url: 'some-url' - }); - - expect(materialDialog.closeAll).toHaveBeenCalled(); - }); }); diff --git a/lib/core/services/auth-guard-bpm.service.ts b/lib/core/services/auth-guard-bpm.service.ts index 2e2a67ec53..eba0ab4a26 100644 --- a/lib/core/services/auth-guard-bpm.service.ts +++ b/lib/core/services/auth-guard-bpm.service.ts @@ -21,7 +21,6 @@ import { AppConfigService } from '../app-config/app-config.service'; import { AuthenticationService } from './authentication.service'; import { AuthGuardBase } from './auth-guard-base'; import { Observable } from 'rxjs'; -import { MatDialog } from '@angular/material'; @Injectable({ providedIn: 'root' @@ -30,10 +29,8 @@ export class AuthGuardBpm extends AuthGuardBase { constructor(authenticationService: AuthenticationService, router: Router, - appConfigService: AppConfigService, - dialog: MatDialog - ) { - super(authenticationService, router, appConfigService, dialog); + appConfigService: AppConfigService) { + super(authenticationService, router, appConfigService); } checkLogin(_: ActivatedRouteSnapshot, redirectUrl: string): Observable | Promise | boolean { diff --git a/lib/core/services/auth-guard-ecm.service.spec.ts b/lib/core/services/auth-guard-ecm.service.spec.ts index 20549d9730..611d14d83a 100644 --- a/lib/core/services/auth-guard-ecm.service.spec.ts +++ b/lib/core/services/auth-guard-ecm.service.spec.ts @@ -22,7 +22,6 @@ import { AuthenticationService } from './authentication.service'; import { RouterStateSnapshot, Router } from '@angular/router'; import { setupTestBed } from '../testing/setupTestBed'; import { CoreTestingModule } from '../testing/core.testing.module'; -import { MatDialog } from '@angular/material'; describe('AuthGuardService ECM', () => { @@ -157,22 +156,4 @@ describe('AuthGuardService ECM', () => { expect(router.navigateByUrl).toHaveBeenCalledWith('/fakeLoginRoute?redirectUrl=some-url'); })); - it('should to close the material dialog if is redirect to the login', () => { - const materialDialog = TestBed.get(MatDialog); - - spyOn(materialDialog, 'closeAll'); - - spyOn(authService, 'setRedirect').and.callThrough(); - spyOn(router, 'navigateByUrl').and.stub(); - const route: RouterStateSnapshot = { url: 'some-url' }; - - authGuard.canActivate(null, route); - - expect(authService.setRedirect).toHaveBeenCalledWith({ - provider: 'ECM', url: 'some-url' - }); - - expect(materialDialog.closeAll).toHaveBeenCalled(); - }); - }); diff --git a/lib/core/services/auth-guard-ecm.service.ts b/lib/core/services/auth-guard-ecm.service.ts index 2a459e7cd2..57292538fa 100644 --- a/lib/core/services/auth-guard-ecm.service.ts +++ b/lib/core/services/auth-guard-ecm.service.ts @@ -23,7 +23,6 @@ import { AuthenticationService } from './authentication.service'; import { AppConfigService } from '../app-config/app-config.service'; import { AuthGuardBase } from './auth-guard-base'; import { Observable } from 'rxjs'; -import { MatDialog } from '@angular/material'; @Injectable({ providedIn: 'root' @@ -32,9 +31,8 @@ export class AuthGuardEcm extends AuthGuardBase { constructor(authenticationService: AuthenticationService, router: Router, - appConfigService: AppConfigService, - dialog: MatDialog) { - super(authenticationService, router, appConfigService, dialog); + appConfigService: AppConfigService) { + super(authenticationService, router, appConfigService); } checkLogin(_: ActivatedRouteSnapshot, redirectUrl: string): Observable | Promise | boolean { diff --git a/lib/core/services/auth-guard-sso-role.service.spec.ts b/lib/core/services/auth-guard-sso-role.service.spec.ts index ceda5fb80f..9b80836547 100644 --- a/lib/core/services/auth-guard-sso-role.service.spec.ts +++ b/lib/core/services/auth-guard-sso-role.service.spec.ts @@ -21,7 +21,6 @@ import { setupTestBed } from '../testing/setupTestBed'; import { CoreTestingModule } from '../testing/core.testing.module'; import { AuthGuardSsoRoleService } from './auth-guard-sso-role.service'; import { JwtHelperService } from './jwt-helper.service'; -import { MatDialog } from '@angular/material'; describe('Auth Guard SSO role service', () => { @@ -165,20 +164,4 @@ describe('Auth Guard SSO role service', () => { expect(authGuard.canActivate(route)).toBeFalsy(); }); - - it('Should canActivate be false hasRealm is true and hasClientRole is false', () => { - const materialDialog = TestBed.get(MatDialog); - - spyOn(materialDialog, 'closeAll'); - - const route: ActivatedRouteSnapshot = new ActivatedRouteSnapshot(); - spyOn(jwtHelperService, 'hasRealmRoles').and.returnValue(true); - spyOn(jwtHelperService, 'hasRealmRolesForClientRole').and.returnValue(false); - - route.params = { appName: 'fakeapp' }; - route.data = { 'clientRoles': ['appName'], 'roles': ['role1', 'role2'] }; - - expect(materialDialog.closeAll).toHaveBeenCalled(); - }); - }); diff --git a/lib/core/services/auth-guard.service.ts b/lib/core/services/auth-guard.service.ts index 2fe90b31b0..762697b9ca 100644 --- a/lib/core/services/auth-guard.service.ts +++ b/lib/core/services/auth-guard.service.ts @@ -22,7 +22,6 @@ import { Observable } from 'rxjs'; import { AppConfigService } from '../app-config/app-config.service'; import { AuthGuardBase } from './auth-guard-base'; import { JwtHelperService } from './jwt-helper.service'; -import { MatDialog } from '@angular/material'; @Injectable({ providedIn: 'root' @@ -34,9 +33,8 @@ export class AuthGuard extends AuthGuardBase { constructor(private jwtHelperService: JwtHelperService, authenticationService: AuthenticationService, router: Router, - appConfigService: AppConfigService, - dialog: MatDialog) { - super(authenticationService, router, appConfigService, dialog); + appConfigService: AppConfigService) { + super(authenticationService, router, appConfigService); this.ticketChangeBind = this.ticketChange.bind(this); window.addEventListener('storage', this.ticketChangeBind); From 02ea026b6bac8a9dbd849dcdaba51ccfc5b841da Mon Sep 17 00:00:00 2001 From: Eugenio Romano Date: Tue, 17 Dec 2019 17:22:06 +0000 Subject: [PATCH 5/7] enanche doc --- docs/core/services/storage.service.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/core/services/storage.service.md b/docs/core/services/storage.service.md index 1b904d49c4..a612536567 100644 --- a/docs/core/services/storage.service.md +++ b/docs/core/services/storage.service.md @@ -61,6 +61,11 @@ In order to achieve this, you will only need to set your app identifier under th **Important note** This identifier must be unique to the app to guarantee that it has its own storage. +### SSO storagePrefix related scenario +The storagePrefix can allow you to login with multiple user in the same browser only if: + - Or You don't use the implicit flow + - Or You use implicit flow you use different AIMS instances for any app + ## See also - [Cookie service](cookie.service.md) From 9ea5bad807b42b6b4325776eb0ea23d133e653bb Mon Sep 17 00:00:00 2001 From: Eugenio Romano Date: Wed, 18 Dec 2019 14:16:36 +0000 Subject: [PATCH 6/7] fix test --- .../components/no-task-detail-template.directive.spec.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/process-services/src/lib/task-list/components/no-task-detail-template.directive.spec.ts b/lib/process-services/src/lib/task-list/components/no-task-detail-template.directive.spec.ts index 4322e1b691..6c10426927 100644 --- a/lib/process-services/src/lib/task-list/components/no-task-detail-template.directive.spec.ts +++ b/lib/process-services/src/lib/task-list/components/no-task-detail-template.directive.spec.ts @@ -27,8 +27,8 @@ describe('NoTaskDetailsTemplateDirective', () => { let authService: AuthenticationService; beforeEach(() => { - authService = new AuthenticationService(null, null, null, null); - spyOn(authService, 'getBpmLoggedUser').and.returnValue(of({ email: 'fake-email'})); + authService = new AuthenticationService(null, null, null, null, null); + spyOn(authService, 'getBpmLoggedUser').and.returnValue(of({ email: 'fake-email' })); detailsComponent = new TaskDetailsComponent(null, authService, null, null, null, null); component = new NoTaskDetailsTemplateDirective(detailsComponent); }); From e4fbd2c3d63789e440825ed64132cb42036b7a85 Mon Sep 17 00:00:00 2001 From: Eugenio Romano Date: Fri, 20 Dec 2019 11:56:12 +0000 Subject: [PATCH 7/7] update e2e --- e2e/core/login/login-component.e2e.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e/core/login/login-component.e2e.ts b/e2e/core/login/login-component.e2e.ts index 89e4debb36..2164a14a08 100644 --- a/e2e/core/login/login-component.e2e.ts +++ b/e2e/core/login/login-component.e2e.ts @@ -208,7 +208,7 @@ describe('Login component', () => { await loginPage.clickSettingsIcon(); await settingsPage.setProviderEcmBpm(); await loginPage.login(adminUserModel.id, adminUserModel.password); - await browser.executeScript('window.localStorage.removeItem("ticket-ECM");'); + await browser.executeScript('window.localStorage.removeItem("ADF_ticket-ECM");'); await BrowserActions.getUrl(browser.params.testConfig.adf.url + '/files'); await loginPage.waitForElements(); }); @@ -228,7 +228,7 @@ describe('Login component', () => { await loginPage.clickSettingsIcon(); await settingsPage.setProviderEcmBpm(); await loginPage.login(adminUserModel.id, adminUserModel.password); - await browser.executeScript('window.localStorage.removeItem("ticket-BPM");'); + await browser.executeScript('window.localStorage.removeItem("ADF_ticket-BPM");'); await BrowserActions.getUrl(browser.params.testConfig.adf.url + '/activiti'); await loginPage.waitForElements(); });