Revert "Removing implicitFlow in favor of codeFlow"

This reverts commit 58951a77b8.
This commit is contained in:
VitoAlbano
2024-06-18 11:18:57 +01:00
parent 8db9934c9b
commit 0107b3b6fe
5 changed files with 59 additions and 33 deletions

View File

@@ -67,10 +67,16 @@
<mat-slide-toggle class="adf-full-width" name="silentLogin" formControlName="silentLogin"> <mat-slide-toggle class="adf-full-width" name="silentLogin" formControlName="silentLogin">
</mat-slide-toggle> </mat-slide-toggle>
<mat-label>Code Flow</mat-label> <mat-label>Implicit Flow</mat-label>
<mat-slide-toggle class="adf-full-width" name="codeFlow" formControlName="codeFlow"> <mat-slide-toggle class="adf-full-width" name="implicitFlow" formControlName="implicitFlow">
</mat-slide-toggle> </mat-slide-toggle>
<ng-container *ngIf="isOAUTH">
<mat-label>Code Flow</mat-label>
<mat-slide-toggle class="adf-full-width" name="codeFlow" formControlName="codeFlow">
</mat-slide-toggle>
</ng-container>
<mat-form-field class="adf-full-width"> <mat-form-field class="adf-full-width">
<mat-label>Redirect URI</mat-label> <mat-label>Redirect URI</mat-label>
<input matInput name="redirectUri" formControlName="redirectUri"> <input matInput name="redirectUri" formControlName="redirectUri">

View File

@@ -150,6 +150,7 @@ export class HostSettingsComponent implements OnInit {
scope: [oauth.scope, Validators.required], scope: [oauth.scope, Validators.required],
secret: oauth.secret, secret: oauth.secret,
silentLogin: oauth.silentLogin, silentLogin: oauth.silentLogin,
implicitFlow: oauth.implicitFlow,
codeFlow: oauth.codeFlow, codeFlow: oauth.codeFlow,
publicUrls: [oauth.publicUrls] publicUrls: [oauth.publicUrls]
}); });
@@ -160,10 +161,7 @@ export class HostSettingsComponent implements OnInit {
} }
private createIdentityFormControl(): UntypedFormControl { private createIdentityFormControl(): UntypedFormControl {
return new UntypedFormControl(this.appConfig.get<string>(AppConfigValues.IDENTITY_HOST), [ return new UntypedFormControl(this.appConfig.get<string>(AppConfigValues.IDENTITY_HOST), [Validators.required, Validators.pattern(HOST_REGEX)]);
Validators.required,
Validators.pattern(HOST_REGEX)
]);
} }
private createECMFormControl(): UntypedFormControl { private createECMFormControl(): UntypedFormControl {
@@ -205,7 +203,7 @@ export class HostSettingsComponent implements OnInit {
} }
private saveOAuthValues(values: any) { 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(','); values.oauthConfig.publicUrls = values.oauthConfig.publicUrls.split(',');
} }
@@ -280,4 +278,5 @@ export class HostSettingsComponent implements OnInit {
get oauthConfig(): UntypedFormControl { get oauthConfig(): UntypedFormControl {
return this.form.get('oauthConfig') as UntypedFormControl; return this.form.get('oauthConfig') as UntypedFormControl;
} }
} }

View File

@@ -63,6 +63,7 @@ export enum Status {
providedIn: 'root' providedIn: 'root'
}) })
export class AppConfigService { export class AppConfigService {
config: any = { config: any = {
application: { application: {
name: 'Alfresco ADF Application' name: 'Alfresco ADF Application'
@@ -96,10 +97,11 @@ export class AppConfigService {
* @returns Property value, when loaded * @returns Property value, when loaded
*/ */
select(property: string): Observable<any> { select(property: string): Observable<any> {
return this.onLoadSubject.pipe( return this.onLoadSubject
map((config) => ObjectUtils.getValue(config, property)), .pipe(
distinctUntilChanged() map((config) => ObjectUtils.getValue(config, property)),
); distinctUntilChanged()
);
} }
/** /**
@@ -168,7 +170,9 @@ export class AppConfigService {
protected onDataLoaded() { protected onDataLoaded() {
this.onLoadSubject.next(this.config); 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) { protected onExtensionsLoaded(config: ExtensionConfig) {
@@ -223,18 +227,20 @@ export class AppConfigService {
* @param hostIdp host address * @param hostIdp host address
* @returns Discovery configuration * @returns Discovery configuration
*/ */
loadWellKnown(hostIdp: string): Promise<OpenidConfiguration> { loadWellKnown(hostIdp: string): Promise<OpenidConfiguration> {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
this.http.get<OpenidConfiguration>(`${hostIdp}/.well-known/openid-configuration`).subscribe({ this.http
next: (res: OpenidConfiguration) => { .get<OpenidConfiguration>(`${hostIdp}/.well-known/openid-configuration`)
resolve(res); .subscribe({
}, next: (res: OpenidConfiguration) => {
error: (err: any) => { resolve(res);
// eslint-disable-next-line no-console },
console.error('hostIdp not correctly configured or unreachable'); error: (err: any) => {
reject(err); // eslint-disable-next-line no-console
} console.error('hostIdp not correctly configured or unreachable');
}); reject(err);
}
});
}); });
} }
@@ -245,11 +251,13 @@ export class AppConfigService {
*/ */
get oauth2(): OauthConfigModel { get oauth2(): OauthConfigModel {
const config = this.get(AppConfigValues.OAUTHCONFIG, {}); const config = this.get(AppConfigValues.OAUTHCONFIG, {});
const implicitFlow = config['implicitFlow'] === true || config['implicitFlow'] === 'true';
const silentLogin = config['silentLogin'] === true || config['silentLogin'] === 'true'; const silentLogin = config['silentLogin'] === true || config['silentLogin'] === 'true';
const codeFlow = config['codeFlow'] === true || config['codeFlow'] === 'true'; const codeFlow = config['codeFlow'] === true || config['codeFlow'] === 'true';
return { return {
...(config as OauthConfigModel), ...(config as OauthConfigModel),
implicitFlow,
silentLogin, silentLogin,
codeFlow codeFlow
}; };
@@ -265,4 +273,5 @@ export class AppConfigService {
return result; return result;
} }
} }

View File

@@ -11,7 +11,7 @@
"url": "https://github.com/Alfresco/alfresco-ng2-components/issues" "url": "https://github.com/Alfresco/alfresco-ng2-components/issues"
}, },
"peerDependencies": { "peerDependencies": {
"@alfresco/js-api": ">=7.9.0-0" "@alfresco/js-api": ">=7.9.0"
}, },
"keywords": [ "keywords": [
"testing", "testing",

View File

@@ -32,8 +32,8 @@ export class SettingsPage {
silentLoginToggleLabel = $(`${materialLocators.Slide.toggle.root}[formcontrolname="silentLogin"] label`); silentLoginToggleLabel = $(`${materialLocators.Slide.toggle.root}[formcontrolname="silentLogin"] label`);
silentLoginToggleElement = $(`${materialLocators.Slide.toggle.root}[formcontrolname="silentLogin"]`); silentLoginToggleElement = $(`${materialLocators.Slide.toggle.root}[formcontrolname="silentLogin"]`);
implicitFlowLabel = $(`${materialLocators.Slide.toggle.root}[formcontrolname="implicitFlow"] label`); implicitFlowLabel = $(`${materialLocators.Slide.toggle.root}[formcontrolname="implicitFlow"] label`);
implicitFlowElement = $(`${materialLocators.Slide.toggle.root}[formcontrolname="implicitFlow"]`);
codeFlowElement = $(`${materialLocators.Slide.toggle.root}[formcontrolname="codeFlow"]`); codeFlowElement = $(`${materialLocators.Slide.toggle.root}[formcontrolname="codeFlow"]`);
codeFlowLabel = $(`${materialLocators.Slide.toggle.root}[formcontrolname="codeFlow"] label`);
applyButton = $('button[data-automation-id="settings-apply-button"]'); applyButton = $('button[data-automation-id="settings-apply-button"]');
providerDropdown = new DropdownPage($(`${materialLocators.Select.root}[id="adf-provider-selector"]`)); providerDropdown = new DropdownPage($(`${materialLocators.Select.root}[id="adf-provider-selector"]`));
@@ -64,9 +64,10 @@ export class SettingsPage {
authHost, authHost,
identityHost, identityHost,
silentLogin = true, silentLogin = true,
codeFlow = true, implicitFlow = true,
clientId?: string, clientId?: string,
logoutUrl: string = '/logout' logoutUrl: string = '/logout',
codeFlow = true
) { ) {
await this.goToSettingsPage(); await this.goToSettingsPage();
await this.setProvider('ECM'); await this.setProvider('ECM');
@@ -74,8 +75,9 @@ export class SettingsPage {
await this.setContentServicesURL(contentServiceURL); await this.setContentServicesURL(contentServiceURL);
await this.setAuthHost(authHost); await this.setAuthHost(authHost);
await this.setIdentityHost(identityHost); await this.setIdentityHost(identityHost);
await this.setCodeFlow(codeFlow);
await this.setSilentLogin(silentLogin); await this.setSilentLogin(silentLogin);
await this.setImplicitFlow(implicitFlow);
await this.setCodeFlow(codeFlow);
await this.setClientId(clientId); await this.setClientId(clientId);
await this.setLogoutUrl(logoutUrl); await this.setLogoutUrl(logoutUrl);
await this.clickApply(); await this.clickApply();
@@ -87,7 +89,7 @@ export class SettingsPage {
authHost, authHost,
identityHost, identityHost,
silentLogin = true, silentLogin = true,
codeFlow = true, implicitFlow = true,
clientId?: string, clientId?: string,
logoutUrl: string = '/logout' logoutUrl: string = '/logout'
) { ) {
@@ -97,8 +99,9 @@ export class SettingsPage {
await this.setContentServicesURL(contentServiceURL); await this.setContentServicesURL(contentServiceURL);
await this.setAuthHost(authHost); await this.setAuthHost(authHost);
await this.setIdentityHost(identityHost); await this.setIdentityHost(identityHost);
await this.setCodeFlow(codeFlow);
await this.setSilentLogin(silentLogin); await this.setSilentLogin(silentLogin);
await this.setCodeFlow(false);
await this.setImplicitFlow(implicitFlow);
await this.setClientId(clientId); await this.setClientId(clientId);
await this.setLogoutUrl(logoutUrl); await this.setLogoutUrl(logoutUrl);
await this.clickApply(); await this.clickApply();
@@ -140,14 +143,23 @@ 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) { async setCodeFlow(enableToggle) {
await BrowserVisibility.waitUntilElementIsVisible(this.codeFlowElement); await BrowserVisibility.waitUntilElementIsVisible(this.codeFlowElement);
const classElements = await BrowserActions.getAttribute(this.codeFlowElement, 'class'); const isChecked = (await BrowserActions.getAttribute(this.codeFlowElement, 'class')).includes(materialLocators.Checked.root);
const isChecked = classElements.includes(materialLocators.Slide.toggle.checked);
if ((isChecked && !enableToggle) || (!isChecked && enableToggle)) { if ((isChecked && !enableToggle) || (!isChecked && enableToggle)) {
await BrowserActions.click(this.codeFlowLabel); await BrowserActions.click(this.codeFlowElement);
} }
} }
} }