From 1000e92ca3123cef7de9ccbe94a68accdbb71a73 Mon Sep 17 00:00:00 2001 From: VitoAlbano Date: Mon, 17 Jun 2024 22:17:56 +0100 Subject: [PATCH] Removing implicitFlow in favor of codeFlow --- .../settings/host-settings.component.html | 10 +---- .../settings/host-settings.component.ts | 9 ++-- .../src/lib/app-config/app-config.service.ts | 41 ++++++++----------- lib/testing/package.json | 2 +- .../protractor/core/pages/settings.page.ts | 30 ++++---------- 5 files changed, 33 insertions(+), 59 deletions(-) diff --git a/demo-shell/src/app/components/settings/host-settings.component.html b/demo-shell/src/app/components/settings/host-settings.component.html index cca0e48ac07..9a147ee5187 100644 --- a/demo-shell/src/app/components/settings/host-settings.component.html +++ b/demo-shell/src/app/components/settings/host-settings.component.html @@ -67,16 +67,10 @@ - Implicit Flow - + Code Flow + - - Code Flow - - - - Redirect URI diff --git a/demo-shell/src/app/components/settings/host-settings.component.ts b/demo-shell/src/app/components/settings/host-settings.component.ts index d5891f2c142..032e088a2eb 100644 --- a/demo-shell/src/app/components/settings/host-settings.component.ts +++ b/demo-shell/src/app/components/settings/host-settings.component.ts @@ -150,7 +150,6 @@ export class HostSettingsComponent implements OnInit { scope: [oauth.scope, Validators.required], secret: oauth.secret, silentLogin: oauth.silentLogin, - implicitFlow: oauth.implicitFlow, codeFlow: oauth.codeFlow, publicUrls: [oauth.publicUrls] }); @@ -161,7 +160,10 @@ export class HostSettingsComponent implements OnInit { } private createIdentityFormControl(): UntypedFormControl { - return new UntypedFormControl(this.appConfig.get(AppConfigValues.IDENTITY_HOST), [Validators.required, Validators.pattern(HOST_REGEX)]); + return new UntypedFormControl(this.appConfig.get(AppConfigValues.IDENTITY_HOST), [ + Validators.required, + Validators.pattern(HOST_REGEX) + ]); } private createECMFormControl(): UntypedFormControl { @@ -203,7 +205,7 @@ export class HostSettingsComponent implements OnInit { } private saveOAuthValues(values: any) { - if (values.oauthConfig.publicUrls && (typeof values.oauthConfig.publicUrls === 'string')) { + if (values.oauthConfig.publicUrls && typeof values.oauthConfig.publicUrls === 'string') { values.oauthConfig.publicUrls = values.oauthConfig.publicUrls.split(','); } @@ -278,5 +280,4 @@ export class HostSettingsComponent implements OnInit { get oauthConfig(): UntypedFormControl { return this.form.get('oauthConfig') as UntypedFormControl; } - } 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 6dd58b4de9b..a55efc394c6 100644 --- a/lib/core/src/lib/app-config/app-config.service.ts +++ b/lib/core/src/lib/app-config/app-config.service.ts @@ -63,7 +63,6 @@ export enum Status { providedIn: 'root' }) export class AppConfigService { - config: any = { application: { name: 'Alfresco ADF Application' @@ -97,11 +96,10 @@ export class AppConfigService { * @returns Property value, when loaded */ select(property: string): Observable { - return this.onLoadSubject - .pipe( - map((config) => ObjectUtils.getValue(config, property)), - distinctUntilChanged() - ); + return this.onLoadSubject.pipe( + map((config) => ObjectUtils.getValue(config, property)), + distinctUntilChanged() + ); } /** @@ -170,9 +168,7 @@ export class AppConfigService { protected onDataLoaded() { this.onLoadSubject.next(this.config); - this.extensionService.setup$ - .pipe(take(1)) - .subscribe((config) => this.onExtensionsLoaded(config)); + this.extensionService.setup$.pipe(take(1)).subscribe((config) => this.onExtensionsLoaded(config)); } protected onExtensionsLoaded(config: ExtensionConfig) { @@ -227,20 +223,18 @@ export class AppConfigService { * @param hostIdp host address * @returns Discovery configuration */ - loadWellKnown(hostIdp: string): Promise { + loadWellKnown(hostIdp: string): Promise { return new Promise((resolve, reject) => { - this.http - .get(`${hostIdp}/.well-known/openid-configuration`) - .subscribe({ - next: (res: OpenidConfiguration) => { - resolve(res); - }, - error: (err: any) => { - // eslint-disable-next-line no-console - console.error('hostIdp not correctly configured or unreachable'); - reject(err); - } - }); + this.http.get(`${hostIdp}/.well-known/openid-configuration`).subscribe({ + next: (res: OpenidConfiguration) => { + resolve(res); + }, + error: (err: any) => { + // eslint-disable-next-line no-console + console.error('hostIdp not correctly configured or unreachable'); + reject(err); + } + }); }); } @@ -251,13 +245,11 @@ export class AppConfigService { */ get oauth2(): OauthConfigModel { const config = this.get(AppConfigValues.OAUTHCONFIG, {}); - const implicitFlow = config['implicitFlow'] === true || config['implicitFlow'] === 'true'; const silentLogin = config['silentLogin'] === true || config['silentLogin'] === 'true'; const codeFlow = config['codeFlow'] === true || config['codeFlow'] === 'true'; return { ...(config as OauthConfigModel), - implicitFlow, silentLogin, codeFlow }; @@ -273,5 +265,4 @@ export class AppConfigService { return result; } - } diff --git a/lib/testing/package.json b/lib/testing/package.json index 0ea2a7c1fc6..97619251f57 100644 --- a/lib/testing/package.json +++ b/lib/testing/package.json @@ -11,7 +11,7 @@ "url": "https://github.com/Alfresco/alfresco-ng2-components/issues" }, "peerDependencies": { - "@alfresco/js-api": ">=7.9.0" + "@alfresco/js-api": ">=7.9.0-0" }, "keywords": [ "testing", diff --git a/lib/testing/src/lib/protractor/core/pages/settings.page.ts b/lib/testing/src/lib/protractor/core/pages/settings.page.ts index 9fed0915ac5..cf73e6a34ae 100644 --- a/lib/testing/src/lib/protractor/core/pages/settings.page.ts +++ b/lib/testing/src/lib/protractor/core/pages/settings.page.ts @@ -32,8 +32,8 @@ export class SettingsPage { silentLoginToggleLabel = $(`${materialLocators.Slide.toggle.root}[formcontrolname="silentLogin"] label`); silentLoginToggleElement = $(`${materialLocators.Slide.toggle.root}[formcontrolname="silentLogin"]`); implicitFlowLabel = $(`${materialLocators.Slide.toggle.root}[formcontrolname="implicitFlow"] label`); - implicitFlowElement = $(`${materialLocators.Slide.toggle.root}[formcontrolname="implicitFlow"]`); codeFlowElement = $(`${materialLocators.Slide.toggle.root}[formcontrolname="codeFlow"]`); + codeFlowLabel = $(`${materialLocators.Slide.toggle.root}[formcontrolname="codeFlow"] label`); applyButton = $('button[data-automation-id="settings-apply-button"]'); providerDropdown = new DropdownPage($(`${materialLocators.Select.root}[id="adf-provider-selector"]`)); @@ -64,10 +64,9 @@ export class SettingsPage { authHost, identityHost, silentLogin = true, - implicitFlow = true, + codeFlow = true, clientId?: string, - logoutUrl: string = '/logout', - codeFlow = true + logoutUrl: string = '/logout' ) { await this.goToSettingsPage(); await this.setProvider('ECM'); @@ -75,9 +74,8 @@ export class SettingsPage { await this.setContentServicesURL(contentServiceURL); await this.setAuthHost(authHost); await this.setIdentityHost(identityHost); - await this.setSilentLogin(silentLogin); - await this.setImplicitFlow(implicitFlow); await this.setCodeFlow(codeFlow); + await this.setSilentLogin(silentLogin); await this.setClientId(clientId); await this.setLogoutUrl(logoutUrl); await this.clickApply(); @@ -89,7 +87,7 @@ export class SettingsPage { authHost, identityHost, silentLogin = true, - implicitFlow = true, + codeFlow = true, clientId?: string, logoutUrl: string = '/logout' ) { @@ -99,9 +97,8 @@ export class SettingsPage { await this.setContentServicesURL(contentServiceURL); await this.setAuthHost(authHost); await this.setIdentityHost(identityHost); + await this.setCodeFlow(codeFlow); await this.setSilentLogin(silentLogin); - await this.setCodeFlow(false); - await this.setImplicitFlow(implicitFlow); await this.setClientId(clientId); await this.setLogoutUrl(logoutUrl); await this.clickApply(); @@ -143,23 +140,14 @@ export class SettingsPage { } } - async setImplicitFlow(enableToggle) { - await BrowserVisibility.waitUntilElementIsVisible(this.implicitFlowElement); - - const isChecked = (await BrowserActions.getAttribute(this.implicitFlowElement, 'class')).includes(materialLocators.Slide.toggle.checked); - - if ((isChecked && !enableToggle) || (!isChecked && enableToggle)) { - await BrowserActions.click(this.implicitFlowLabel); - } - } - async setCodeFlow(enableToggle) { await BrowserVisibility.waitUntilElementIsVisible(this.codeFlowElement); - const isChecked = (await BrowserActions.getAttribute(this.codeFlowElement, 'class')).includes(materialLocators.Checked.root); + const classElements = await BrowserActions.getAttribute(this.codeFlowElement, 'class'); + const isChecked = classElements.includes(materialLocators.Slide.toggle.checked); if ((isChecked && !enableToggle) || (!isChecked && enableToggle)) { - await BrowserActions.click(this.codeFlowElement); + await BrowserActions.click(this.codeFlowLabel); } } }