From bb1c2a86391e5e70a1ba169390eae1473daaeebe Mon Sep 17 00:00:00 2001 From: Andras Popovics Date: Thu, 26 Jan 2023 20:01:54 +0100 Subject: [PATCH] Fix cancary serve --- angular.json | 3 +++ demo-shell/src/app.config.json | 4 ++-- demo-shell/src/app/app.module.ts | 16 ++++++++-------- lib/core/auth/src/lib/auth.module.ts | 3 ++- .../src/lib/services/auth-config.service.ts | 19 ++----------------- .../src/lib/app-config/app-config.service.ts | 6 +++--- .../app-config/debug-app-config.service.ts | 2 +- lib/core/src/lib/core.module.ts | 1 - 8 files changed, 21 insertions(+), 33 deletions(-) diff --git a/angular.json b/angular.json index edf769730d..5a3820f967 100644 --- a/angular.json +++ b/angular.json @@ -251,6 +251,9 @@ }, "e2e": { "browserTarget": "demoshell:build:e2e" + }, + "canary": { + "browserTarget": "demoshell:build:canary" } } }, diff --git a/demo-shell/src/app.config.json b/demo-shell/src/app.config.json index 35cfe0fef9..b063ad785b 100644 --- a/demo-shell/src/app.config.json +++ b/demo-shell/src/app.config.json @@ -19,8 +19,8 @@ "issuer": "{protocol}//{hostname}{:port}/auth/realms/alfresco", "loginUrl": "{protocol}//{hostname}{:port}/auth/realms/alfresco/protocol/openid-connect/auth", "silentRefreshRedirectUri": "{protocol}//{hostname}{:port}/assets/silent-refresh.html", - "redirectUri": "/", - "postLogoutRedirectUri": "#/logout", + "redirectUri": "{protocol}//{hostname}{:port}/", + "postLogoutRedirectUri": "{protocol}//{hostname}{:port}/#/logout", "clientId": "alfresco", "scope": "openid profile email", "responseType": "code" diff --git a/demo-shell/src/app/app.module.ts b/demo-shell/src/app/app.module.ts index 0a658ff5e9..84c870a51b 100644 --- a/demo-shell/src/app/app.module.ts +++ b/demo-shell/src/app/app.module.ts @@ -135,12 +135,17 @@ registerLocaleData(localeFi); registerLocaleData(localeDa); registerLocaleData(localeSv); -debugger; - @NgModule({ imports: [ BrowserModule, environment.e2e ? NoopAnimationsModule : BrowserAnimationsModule, + ReactiveFormsModule, + FormsModule, + HttpClientModule, + MaterialModule, + FlexLayoutModule, + TranslateModule.forRoot(), + ...(environment.oidc ? [ // Initial navigation must be disabled when we use the OIDC package with HashLocationStrategy, check its documentation @@ -165,12 +170,7 @@ debugger; CoreModule.forRoot({ authByJsApi: true }) ] ), - ReactiveFormsModule, - FormsModule, - HttpClientModule, - MaterialModule, - FlexLayoutModule, - TranslateModule.forRoot(), + ContentModule.forRoot(), InsightsModule.forRoot(), ProcessModule.forRoot(), diff --git a/lib/core/auth/src/lib/auth.module.ts b/lib/core/auth/src/lib/auth.module.ts index 41782fba75..a72958b5f4 100644 --- a/lib/core/auth/src/lib/auth.module.ts +++ b/lib/core/auth/src/lib/auth.module.ts @@ -35,7 +35,8 @@ import { AuthConfigService, configureAuth } from './services/auth-config.service { provide: APP_INITIALIZER, useFactory: configureAuth, - deps: [ AuthConfigService ] + deps: [ AuthConfigService ], + multi: true }, // TODO: CANARY: This is temporary, we are reproviding ADF's AuthenticationService with our own implementation to work with the new auth library // TODO: But we need definitely need a cleaner solution for this. Which means, first we need to make the apis capable of handling multiple http clients diff --git a/lib/core/auth/src/lib/services/auth-config.service.ts b/lib/core/auth/src/lib/services/auth-config.service.ts index b1cb6401dd..94d786caad 100644 --- a/lib/core/auth/src/lib/services/auth-config.service.ts +++ b/lib/core/auth/src/lib/services/auth-config.service.ts @@ -23,7 +23,7 @@ import { Router } from '@angular/router'; import { StorageService } from '@alfresco/adf-core/common'; import { AppConfigService, AppConfigValues } from '@alfresco/adf-core/config'; -export const configureAuth = (oidcAuthentication: AuthConfigService) => () => oidcAuthentication.init(); +export const configureAuth = (oidcAuthentication: AuthConfigService) => () => oidcAuthentication.load(); @Injectable() export class AuthConfigService { @@ -37,8 +37,7 @@ export class AuthConfigService { private router: Router ) {} - public init() { - debugger; + public load() { this.appConfigService.onLoad .pipe(take(1)) .toPromise() @@ -64,18 +63,4 @@ export class AuthConfigService { isCodeFlow(): boolean { return this._authConfig.responseType === 'code'; } - - // private getAuthConfig(codeFlow = false): AuthConfig { - // const oauth2: OauthConfigModel = Object.assign({}); - // return { - // issuer: oauth2.host, - // loginUrl: `${oauth2.host}/protocol/openid-connect/auth`, - // silentRefreshRedirectUri: oauth2.redirectSilentIframeUri, - // redirectUri: window.location.origin + oauth2.redirectUri, - // postLogoutRedirectUri: window.location.origin + oauth2.redirectUriLogout, - // clientId: oauth2.clientId, - // scope: oauth2.scope, - // ...(codeFlow ? { responseType: 'code' } : {}) - // }; - // } } 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 613e6debeb..ff0340a895 100644 --- a/lib/core/src/lib/app-config/app-config.service.ts +++ b/lib/core/src/lib/app-config/app-config.service.ts @@ -116,9 +116,9 @@ export class AppConfigService { } if (typeof result === 'object') { - result = JSON.parse(JSON.stringify(result).replace('{hostname}', this.getLocationHostname())); - result = JSON.parse(JSON.stringify(result).replace('{:port}', this.getLocationPort(':'))); - result = JSON.parse(JSON.stringify(result).replace('{protocol}', this.getLocationProtocol())); + result = JSON.parse(JSON.stringify(result).replace(/\{hostname\}/g, this.getLocationHostname())); + result = JSON.parse(JSON.stringify(result).replace(/\{\:port\}/g, this.getLocationPort(':'))); + result = JSON.parse(JSON.stringify(result).replace(/\{protocol\}/g, this.getLocationProtocol())); } if (result === undefined) { diff --git a/lib/core/src/lib/app-config/debug-app-config.service.ts b/lib/core/src/lib/app-config/debug-app-config.service.ts index 4b6f7a48b5..c029f121e5 100644 --- a/lib/core/src/lib/app-config/debug-app-config.service.ts +++ b/lib/core/src/lib/app-config/debug-app-config.service.ts @@ -29,7 +29,7 @@ export class DebugAppConfigService extends AppConfigService { /** @override */ get(key: string, defaultValue?: T): T { - if (key === AppConfigValues.OAUTHCONFIG) { + if (key === AppConfigValues.OAUTHCONFIG || key === AppConfigValues.AUTH_CONFIG) { return (JSON.parse(this.storage.getItem(key)) || super.get(key, defaultValue)); } else if (key === AppConfigValues.APPLICATION) { return undefined; diff --git a/lib/core/src/lib/core.module.ts b/lib/core/src/lib/core.module.ts index 222f6096ba..b9c57acb67 100644 --- a/lib/core/src/lib/core.module.ts +++ b/lib/core/src/lib/core.module.ts @@ -151,7 +151,6 @@ const defaultConfig: LegacyMonolithCoreModuleConfig = { }) export class CoreModule { static forRoot(config: LegacyMonolithCoreModuleConfig = defaultConfig): ModuleWithProviders { - debugger; return { ngModule: CoreModule, providers: [