[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

@@ -54,6 +54,10 @@ export class AuthenticationService {
return !!this.alfrescoApi.getInstance().isLoggedIn();
}
isOauth(): boolean {
return this.alfrescoApi.getInstance().isOauthConfiguration();
}
/**
* Logs the user in.
* @param username Username for the login
@@ -63,19 +67,26 @@ export class AuthenticationService {
*/
login(username: string, password: string, rememberMe: boolean = false): Observable<{ type: string, ticket: any }> {
this.removeTicket();
return Observable.fromPromise(this.callApiLogin(username, password))
return Observable.fromPromise(this.alfrescoApi.getInstance().login(username, password))
.map((response: any) => {
this.saveRememberMeCookie(rememberMe);
this.saveTickets();
this.onLogin.next(response);
return {
type: this.preferences.authType,
type: this.preferences.providers,
ticket: response
};
})
.catch(err => this.handleError(err));
}
/**
* Logs the user in with SSO
*/
ssoImplictiLogin() {
this.alfrescoApi.getInstance().implicitLogin();
}
/**
* Saves the "remember me" cookie as either a long-life cookie or a session cookie.
* @param rememberMe Enables a long-life cookie
@@ -100,15 +111,6 @@ export class AuthenticationService {
return (this.cookie.getItem(REMEMBER_ME_COOKIE_KEY) === null) ? false : true;
}
/**
* Initialize the alfresco Api with user and password end call the login method
* @param username
* @param password
*/
private callApiLogin(username: string, password: string) {
return this.alfrescoApi.getInstance().login(username, password);
}
/**
* Logs the user out.
* @returns Response event called when logout is complete
@@ -213,7 +215,7 @@ export class AuthenticationService {
if (this.cookie.isEnabled() && !this.isRememberMeSet()) {
return false;
}
return this.alfrescoApi.getInstance().ecmAuth && !!this.alfrescoApi.getInstance().ecmAuth.isLoggedIn();
return this.alfrescoApi.getInstance().isEcmLoggedIn();
}
/**
@@ -224,7 +226,7 @@ export class AuthenticationService {
if (this.cookie.isEnabled() && !this.isRememberMeSet()) {
return false;
}
return this.alfrescoApi.getInstance().bpmAuth && !!this.alfrescoApi.getInstance().bpmAuth.isLoggedIn();
return this.alfrescoApi.getInstance().isBpmLoggedIn();
}
/**
@@ -232,7 +234,7 @@ export class AuthenticationService {
* @returns The ECM username
*/
getEcmUsername(): string {
return this.alfrescoApi.getInstance().ecmAuth.username;
return this.alfrescoApi.getInstance().getEcmUsername();
}
/**
@@ -240,7 +242,7 @@ export class AuthenticationService {
* @returns The BPM username
*/
getBpmUsername(): string {
return this.alfrescoApi.getInstance().bpmAuth.username;
return this.alfrescoApi.getInstance().getBpmUsername();
}
/** Sets the URL to redirect to after login.