From 26c217cc2de013abbb29466bc92878f7eb9f2956 Mon Sep 17 00:00:00 2001 From: eromano Date: Thu, 27 Jul 2023 18:33:38 +0200 Subject: [PATCH] fix not silent login --- e2e/test.config.js | 8 ++++---- .../api-factories/alfresco-api-v2-loader.service.ts | 5 ++++- lib/core/src/lib/app-config/app-config.service.ts | 4 +++- lib/core/src/lib/auth/basic-auth/content-auth.ts | 10 ++++------ lib/core/src/lib/auth/basic-auth/process-auth.ts | 7 +++---- 5 files changed, 18 insertions(+), 16 deletions(-) diff --git a/e2e/test.config.js b/e2e/test.config.js index bd1effdba9..34bab52016 100644 --- a/e2e/test.config.js +++ b/e2e/test.config.js @@ -9,14 +9,14 @@ const HOST = process.env.URL_HOST_ADF; const LOG = process.env.E2E_LOG_LEVEL; -const HOST_ECM = process.env.PROXY_HOST_ECM || HOST || 'ecm'; -const HOST_BPM = process.env.PROXY_HOST_BPM || HOST || 'bpm'; +const HOST_ECM = process.env.PROXY_HOST_ECM || process.env.PROXY_HOST_ADF || HOST || 'ecm'; +const HOST_BPM = process.env.PROXY_HOST_BPM || process.env.PROXY_HOST_ADF || HOST || 'bpm'; +const HOST_SSO = process.env.HOST_SSO || process.env.PROXY_HOST_ADF || HOST || 'oauth'; +const IDENTITY_HOST = process.env.IDENTITY_HOST || process.env.HOST_SSO + '/auth/admin/realms/alfresco'; const PROVIDER = process.env.PROVIDER ? process.env.PROVIDER : 'ALL'; const AUTH_TYPE = process.env.AUTH_TYPE ? process.env.AUTH_TYPE : 'BASIC'; -const HOST_SSO = process.env.HOST_SSO || process.env.PROXY_HOST_ADF || HOST || 'oauth'; -const IDENTITY_HOST = process.env.IDENTITY_HOST || process.env.HOST_SSO + '/auth/admin/realms/alfresco'; const OAUTH_CLIENT_ID = process.env.OAUTH_CLIENDID || 'alfresco'; const IDENTITY_ADMIN_EMAIL = process.env.IDENTITY_ADMIN_EMAIL || "defaultadmin"; diff --git a/lib/core/src/lib/api-factories/alfresco-api-v2-loader.service.ts b/lib/core/src/lib/api-factories/alfresco-api-v2-loader.service.ts index 098c16e9ba..310a55378b 100644 --- a/lib/core/src/lib/api-factories/alfresco-api-v2-loader.service.ts +++ b/lib/core/src/lib/api-factories/alfresco-api-v2-loader.service.ts @@ -19,6 +19,7 @@ import { AlfrescoApiConfig } from '@alfresco/js-api'; import { Injectable } from '@angular/core'; import { AppConfigService, AppConfigValues } from '../app-config/app-config.service'; import { AlfrescoApiService } from '../services/alfresco-api.service'; +import { StorageService } from "../common"; export function createAlfrescoApiInstance(angularAlfrescoApiService: AlfrescoApiLoaderService) { return () => angularAlfrescoApiService.init(); @@ -28,7 +29,7 @@ export function createAlfrescoApiInstance(angularAlfrescoApiService: AlfrescoApi providedIn: 'root' }) export class AlfrescoApiLoaderService { - constructor(private readonly appConfig: AppConfigService, private readonly apiService: AlfrescoApiService) {} + constructor(private readonly appConfig: AppConfigService, private readonly apiService: AlfrescoApiService, private storageService: StorageService) {} async init(): Promise { await this.appConfig.load(); @@ -53,6 +54,8 @@ export class AlfrescoApiLoaderService { disableCsrf: this.appConfig.get(AppConfigValues.DISABLECSRF), withCredentials: this.appConfig.get(AppConfigValues.AUTH_WITH_CREDENTIALS, false), domainPrefix: this.appConfig.get(AppConfigValues.STORAGE_PREFIX), + ticketEcm: this.storageService.getItem(AppConfigValues.CONTENT_TICKET_STORAGE_LABEL), + ticketBpm: this.storageService.getItem(AppConfigValues.PROCESS_TICKET_STORAGE_LABEL), oauth2: oauth }); diff --git a/lib/core/src/lib/app-config/app-config.service.ts b/lib/core/src/lib/app-config/app-config.service.ts index e7c6915b30..e8ce94ab08 100644 --- a/lib/core/src/lib/app-config/app-config.service.ts +++ b/lib/core/src/lib/app-config/app-config.service.ts @@ -45,7 +45,9 @@ export enum AppConfigValues { AUTH_WITH_CREDENTIALS = 'auth.withCredentials', APPLICATION = 'application', STORAGE_PREFIX = 'application.storagePrefix', - NOTIFY_DURATION = 'notificationDefaultDuration' + NOTIFY_DURATION = 'notificationDefaultDuration', + CONTENT_TICKET_STORAGE_LABEL = 'ticket-ECM', + PROCESS_TICKET_STORAGE_LABEL = 'ticket-BPM' } // eslint-disable-next-line no-shadow diff --git a/lib/core/src/lib/auth/basic-auth/content-auth.ts b/lib/core/src/lib/auth/basic-auth/content-auth.ts index 1a65001e13..8b08e5ed3f 100644 --- a/lib/core/src/lib/auth/basic-auth/content-auth.ts +++ b/lib/core/src/lib/auth/basic-auth/content-auth.ts @@ -34,8 +34,6 @@ export interface TicketEntry { }; } -export const CONTENT_TICKET_STORAGE_LABEL = 'ticket-ECM'; - @Injectable({ providedIn: 'root' }) @@ -71,8 +69,8 @@ export class ContentAuth { } private setConfig() { - if (this.storageService.getItem(CONTENT_TICKET_STORAGE_LABEL)) { - this.setTicket(this.storageService.getItem(CONTENT_TICKET_STORAGE_LABEL)); + if (this.storageService.getItem(AppConfigValues.CONTENT_TICKET_STORAGE_LABEL)) { + this.setTicket(this.storageService.getItem(AppConfigValues.CONTENT_TICKET_STORAGE_LABEL)); } } @@ -157,7 +155,7 @@ export class ContentAuth { this.authentications.basicAuth.username = 'ROLE_TICKET'; this.authentications.basicAuth.password = ticket; this.config.ticketEcm = ticket; - this.storageService.setItem(CONTENT_TICKET_STORAGE_LABEL, ticket); + this.storageService.setItem(AppConfigValues.CONTENT_TICKET_STORAGE_LABEL, ticket); this.ticket = ticket; } @@ -173,7 +171,7 @@ export class ContentAuth { } invalidateSession() { - this.storageService.removeItem(CONTENT_TICKET_STORAGE_LABEL); + this.storageService.removeItem(AppConfigValues.CONTENT_TICKET_STORAGE_LABEL); this.authentications.basicAuth.username = null; this.authentications.basicAuth.password = null; this.config.ticketEcm = null; diff --git a/lib/core/src/lib/auth/basic-auth/process-auth.ts b/lib/core/src/lib/auth/basic-auth/process-auth.ts index 17618731c2..e27cd2129a 100644 --- a/lib/core/src/lib/auth/basic-auth/process-auth.ts +++ b/lib/core/src/lib/auth/basic-auth/process-auth.ts @@ -22,7 +22,6 @@ import { AppConfigService, AppConfigValues } from '../../app-config/app-config.s import { StorageService } from '../../common/services/storage.service'; import { ReplaySubject, Subject } from 'rxjs'; -export const PROCESS_TICKET_STORAGE_LABEL = 'ticket-BPM'; @Injectable({ providedIn: 'root' @@ -58,7 +57,7 @@ export class ProcessAuth { private setConfig() { this.ticket = undefined; - this.setTicket(this.storageService.getItem(PROCESS_TICKET_STORAGE_LABEL)); + this.setTicket(this.storageService.getItem(AppConfigValues.PROCESS_TICKET_STORAGE_LABEL)); } saveUsername(username: string) { @@ -171,13 +170,13 @@ export class ProcessAuth { this.authentications.basicAuth.ticket = ticket; this.authentications.basicAuth.password = null; this.config.ticketBpm = ticket; - this.storageService.setItem(PROCESS_TICKET_STORAGE_LABEL, ticket); + this.storageService.setItem(AppConfigValues.PROCESS_TICKET_STORAGE_LABEL, ticket); this.ticket = ticket; } } invalidateSession() { - this.storageService.removeItem(PROCESS_TICKET_STORAGE_LABEL); + this.storageService.removeItem(AppConfigValues.PROCESS_TICKET_STORAGE_LABEL); this.authentications.basicAuth.ticket = null; this.authentications.basicAuth.password = null; this.authentications.basicAuth.username = null;