support for SSO settings (#905)

This commit is contained in:
Denys Vuika 2019-01-22 16:43:26 +00:00 committed by GitHub
parent b61b54d5e9
commit a12c60337d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 75 additions and 29 deletions

View File

@ -4,7 +4,7 @@
"providers": "ECM",
"authType": "BASIC",
"oauth2": {
"host": "http://localhost:8081/auth/realms/alfresco",
"host": "http://localhost:4200/auth/realms/alfresco",
"clientId": "alfresco",
"scope": "openid",
"secret": "",

View File

@ -23,14 +23,9 @@
(ngSubmit)="apply(form.value, form.valid)"
>
<div>
<mat-form-field class="settings-input">
<input
matInput
formControlName="ecmHost"
type="text"
tabindex="2"
placeholder="ACS Repository URL"
/>
<mat-form-field class="settings-input" appearance="outline">
<mat-label>ACS Repository URL</mat-label>
<input matInput formControlName="ecmHost" type="text" />
<mat-error *ngIf="form.get('ecmHost').hasError('pattern')">
{{ 'APP.SETTINGS.INVALID-VALUE-FORMAT' | translate }}
</mat-error>
@ -40,6 +35,23 @@
</mat-form-field>
</div>
<div>
<mat-form-field class="settings-input" appearance="outline">
<mat-label>Authentication Type</mat-label>
<mat-select formControlName="authType">
<mat-option value="BASIC">Basic</mat-option>
<mat-option value="OAUTH">OAuth (Identity Service)</mat-option>
</mat-select>
</mat-form-field>
</div>
<div>
<mat-form-field class="settings-input" appearance="outline">
<mat-label>Alfresco Identity Service URL</mat-label>
<input matInput formControlName="aisHost" type="text" />
</mat-form-field>
</div>
<div class="settings-buttons">
<button mat-button (click)="reset()">
{{ 'APP.SETTINGS.RESET' | translate }}
@ -70,19 +82,21 @@
</mat-checkbox>
</mat-expansion-panel>
<mat-expansion-panel *ngIf="(profile$ | async)?.isAdmin">
<mat-expansion-panel-header>
<mat-panel-title>
{{ 'APP.SETTINGS.EXPERIMENTAL-FEATURES' | translate }}
</mat-panel-title>
</mat-expansion-panel-header>
<div *ngFor="let flag of experimental">
<mat-checkbox
[(ngModel)]="flag.value"
(change)="onToggleExperimentalFeature(flag.key, $event)"
>
{{ flag.key }}
</mat-checkbox>
</div>
</mat-expansion-panel>
<ng-container *ngIf="experimental.length">
<mat-expansion-panel *ngIf="(profile$ | async)?.isAdmin">
<mat-expansion-panel-header>
<mat-panel-title>
{{ 'APP.SETTINGS.EXPERIMENTAL-FEATURES' | translate }}
</mat-panel-title>
</mat-expansion-panel-header>
<div *ngFor="let flag of experimental">
<mat-checkbox
[(ngModel)]="flag.value"
(change)="onToggleExperimentalFeature(flag.key, $event)"
>
{{ flag.key }}
</mat-checkbox>
</div>
</mat-expansion-panel>
</ng-container>
</mat-accordion>

View File

@ -24,7 +24,11 @@
*/
import { Component, ViewEncapsulation, OnInit } from '@angular/core';
import { AppConfigService, StorageService } from '@alfresco/adf-core';
import {
AppConfigService,
StorageService,
OauthConfigModel
} from '@alfresco/adf-core';
import { Validators, FormGroup, FormBuilder } from '@angular/forms';
import { Observable } from 'rxjs';
import { Store } from '@ngrx/store';
@ -39,6 +43,12 @@ import { MatCheckboxChange } from '@angular/material';
import { SetLanguagePickerAction } from '../../store/actions';
import { ProfileState } from '@alfresco/adf-extensions';
interface RepositoryConfig {
ecmHost: string;
authType: string;
aisHost: string;
}
@Component({
selector: 'aca-settings',
templateUrl: './settings.component.html',
@ -77,7 +87,12 @@ export class SettingsComponent implements OnInit {
ecmHost: [
'',
[Validators.required, Validators.pattern('^(http|https)://.*[^/]$')]
]
],
aisHost: [
'',
[Validators.required, Validators.pattern('^(http|https)://.*[^/]$')]
],
authType: ['']
});
this.reset();
@ -92,17 +107,34 @@ export class SettingsComponent implements OnInit {
});
}
apply(model: any, isValid: boolean) {
apply(model: RepositoryConfig, isValid: boolean) {
if (isValid) {
this.storage.setItem('ecmHost', model.ecmHost);
this.storage.setItem('authType', model.authType);
const config: OauthConfigModel = this.appConfig.get<OauthConfigModel>(
'oauth2',
null
);
config.host = model.aisHost;
this.storage.setItem('oauth2', JSON.stringify(config));
// window.location.reload(true);
}
}
reset() {
this.form.reset({
const config: OauthConfigModel = this.appConfig.get<OauthConfigModel>(
'oauth2',
null
);
this.form.reset(<RepositoryConfig>{
ecmHost:
this.storage.getItem('ecmHost') || this.appConfig.get<string>('ecmHost')
this.storage.getItem('ecmHost') ||
this.appConfig.get<string>('ecmHost'),
aisHost: config.host,
authType: this.appConfig.get<string>('authType')
});
}