[ADF-2795] SSO implicitflow (#3332)

* Enable OAUTH2

* Create SSO services

* SSO improvements

* Rollback sso login change

* Add SSO configuration from Setting component

* Refactoring

* Remove login ECM/BPM toggle and move use the userpreference instead of store

* fix host setting unit test

* Fix unit test missing instance

* use the Js api oauth

* add logout component and clean sso not used class

* fix dependencies cicle

* add translation settings

* fix style setting page

* clean

* JS APi should receive the oauth config from the userPreference and not from the config file

* change login if SSO is present

* missing spaces

* add sso test in login component

* add logout directive new properties test

* Improve host setting and remove library reference

* fix login test

* Remove unused code

* Fix authentication unit test

* fix authguard unit test

* fix csrf check login component

* fix unit test core and demo shell

* remove
This commit is contained in:
Maurizio Vitale
2018-06-07 23:19:58 +01:00
committed by Eugenio Romano
parent 3a6c12e624
commit f8e92b2fb0
57 changed files with 1295 additions and 681 deletions

View File

@@ -20,9 +20,9 @@ import { TranslateService } from '@ngx-translate/core';
import { BehaviorSubject } from 'rxjs/BehaviorSubject';
import { Observable } from 'rxjs/Observable';
import { AppConfigService } from '../app-config/app-config.service';
import { AlfrescoApiService } from './alfresco-api.service';
import { StorageService } from './storage.service';
import 'rxjs/add/operator/distinctUntilChanged';
import { OauthConfigModel } from '../models/oauth-config.model';
export enum UserPreferenceValues {
PaginationSize = 'PAGINATION_SIZE',
@@ -50,17 +50,14 @@ export class UserPreferencesService {
* @deprecated we are grouping every value changed on the user preference in a single stream : userPreferenceValue$
*/
locale$: Observable<string>;
private localeSubject: BehaviorSubject<string> ;
private localeSubject: BehaviorSubject<string>;
private onChangeSubject: BehaviorSubject<any>;
onChange: Observable<any>;
constructor(
public translate: TranslateService,
private appConfig: AppConfigService,
private storage: StorageService,
private apiService: AlfrescoApiService
) {
constructor(public translate: TranslateService,
private appConfig: AppConfigService,
private storage: StorageService) {
this.appConfig.onLoad.subscribe(this.initUserPreferenceStatus.bind(this));
this.localeSubject = new BehaviorSubject(this.userPreferenceStatus[UserPreferenceValues.Locale]);
this.locale$ = this.localeSubject.asObservable();
@@ -106,7 +103,9 @@ export class UserPreferencesService {
* @param value New value for the property
*/
set(property: string, value: any) {
if (!property) { return; }
if (!property) {
return;
}
this.storage.setItem(
this.getPropertyKey(property),
value
@@ -149,19 +148,29 @@ export class UserPreferencesService {
}
/** Authorization type (can be "ECM", "BPM" or "ALL"). */
set authType(value: string) {
this.storage.setItem('AUTH_TYPE', value);
this.apiService.reset();
/** @deprecated in 2.4.0 */
set authType(authType: string) {
let storedAuthType = this.storage.getItem('AUTH_TYPE');
if (authType !== storedAuthType) {
this.storage.setItem('AUTH_TYPE', authType);
}
}
/** @deprecated in 2.4.0 */
get authType(): string {
return this.storage.getItem('AUTH_TYPE') || 'ALL';
}
/** Prevents the CSRF Token from being submitted if true. Only valid for Process Services. */
set disableCSRF(value: boolean) {
this.set('DISABLE_CSRF', value);
this.apiService.reset();
set disableCSRF(csrf: boolean) {
let storedCSRF = this.storage.getItem('DISABLE_CSRF');
if (csrf !== null && csrf !== undefined) {
if (csrf.toString() === storedCSRF) {
this.set('DISABLE_CSRF', csrf);
}
}
}
get disableCSRF(): boolean {
@@ -196,4 +205,56 @@ export class UserPreferencesService {
return this.appConfig.get<string>('locale') || this.translate.getBrowserLang() || 'en';
}
get providers(): string {
if (this.storage.hasItem('providers')) {
return this.storage.getItem('providers');
} else {
return this.appConfig.get('providers', 'ECM');
}
}
set providers(providers: string) {
this.storage.setItem('providers', providers);
}
get bpmHost(): string {
if (this.storage.hasItem('bpmHost')) {
return this.storage.getItem('bpmHost');
} else {
return this.appConfig.get('bpmHost');
}
}
set bpmHost(bpmHost: string) {
this.storage.setItem('bpmHost', bpmHost);
}
get ecmHost(): string {
if (this.storage.hasItem('ecmHost')) {
return this.storage.getItem('ecmHost');
} else {
return this.appConfig.get('ecmHost');
}
}
set ecmHost(ecmHost: string) {
this.storage.setItem('ecmHost', ecmHost);
}
get oauthConfig(): OauthConfigModel {
if (this.storage.hasItem('oauthConfig')) {
return JSON.parse(this.storage.getItem('oauthConfig'));
} else {
return this.appConfig.get<OauthConfigModel>('oauth2');
}
}
set oauthConfig(oauthConfig: OauthConfigModel) {
this.storage.setItem('oauthConfig', JSON.stringify(oauthConfig));
}
get sso(): boolean {
return this.providers === 'OAUTH' && this.oauthConfig.implicitFlow;
}
}