mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-5465] Not being redirected to login page when Kerberos is enabled (#7272)
* Revert "[MNT-22334] ADW - User information not displayed when Kerberos is in use (#7172)"
This reverts commit 4befb779
* [ADF-5465] Not being redirected to login page when Kerberos is enabled
* * fix user info
* * add providers
* * fix test
This commit is contained in:
@@ -16,13 +16,13 @@
|
||||
*/
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable, from, throwError, Observer, ReplaySubject } from 'rxjs';
|
||||
import { Observable, from, throwError, Observer, ReplaySubject, forkJoin } from 'rxjs';
|
||||
import { AlfrescoApiService } from './alfresco-api.service';
|
||||
import { CookieService } from './cookie.service';
|
||||
import { LogService } from './log.service';
|
||||
import { RedirectionModel } from '../models/redirection.model';
|
||||
import { AppConfigService, AppConfigValues } from '../app-config/app-config.service';
|
||||
import { UserProfileApi, UserRepresentation } from '@alfresco/js-api';
|
||||
import { PeopleApi, UserProfileApi, UserRepresentation } from '@alfresco/js-api';
|
||||
import { map, catchError, tap } from 'rxjs/operators';
|
||||
import { HttpHeaders } from '@angular/common/http';
|
||||
import { JwtHelperService } from './jwt-helper.service';
|
||||
@@ -39,7 +39,7 @@ export class AuthenticationService {
|
||||
|
||||
private bearerExcludedUrls: string[] = ['auth/realms', 'resources/', 'assets/'];
|
||||
/**
|
||||
* Emits Basic auth login event
|
||||
* Emits login event
|
||||
*/
|
||||
onLogin: ReplaySubject<any> = new ReplaySubject<any>(1);
|
||||
|
||||
@@ -48,6 +48,12 @@ export class AuthenticationService {
|
||||
*/
|
||||
onLogout: ReplaySubject<any> = new ReplaySubject<any>(1);
|
||||
|
||||
_peopleApi: PeopleApi;
|
||||
get peopleApi(): PeopleApi {
|
||||
this._peopleApi = this._peopleApi ?? new PeopleApi(this.alfrescoApi.getInstance());
|
||||
return this._peopleApi;
|
||||
}
|
||||
|
||||
_profileApi: UserProfileApi;
|
||||
get profileApi(): UserProfileApi {
|
||||
this._profileApi = this._profileApi ?? new UserProfileApi(this.alfrescoApi.getInstance());
|
||||
@@ -64,18 +70,31 @@ export class AuthenticationService {
|
||||
this.alfrescoApi.getInstance().reply('logged-in', () => {
|
||||
this.onLogin.next();
|
||||
});
|
||||
|
||||
if (this.isKerberosEnabled()) {
|
||||
this.loadUserDetails();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private loadUserDetails() {
|
||||
const ecmUser$ = from(this.peopleApi.getPerson('-me-'));
|
||||
const bpmUser$ = this.getBpmLoggedUser();
|
||||
|
||||
if (this.isALLProvider()) {
|
||||
forkJoin([ecmUser$, bpmUser$]).subscribe(() => this.onLogin.next());
|
||||
} else if (this.isECMProvider()) {
|
||||
ecmUser$.subscribe(() => this.onLogin.next());
|
||||
} else {
|
||||
bpmUser$.subscribe(() => this.onLogin.next());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the user logged in.
|
||||
* @returns True if logged in, false otherwise
|
||||
*/
|
||||
isLoggedIn(): boolean {
|
||||
if (this.isKerberosConfigured()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!this.isOauth() && this.cookie.isEnabled() && !this.isRememberMeSet()) {
|
||||
return false;
|
||||
}
|
||||
@@ -92,6 +111,14 @@ export class AuthenticationService {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Does kerberos enabled?
|
||||
* @returns True if enabled, false otherwise
|
||||
*/
|
||||
isKerberosEnabled(): boolean {
|
||||
return this.appConfig.get<boolean>(AppConfigValues.AUTH_WITH_CREDENTIALS, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Does the provider support OAuth?
|
||||
* @returns True if supported, false otherwise
|
||||
@@ -236,10 +263,6 @@ export class AuthenticationService {
|
||||
* @returns True if logged in, false otherwise
|
||||
*/
|
||||
isEcmLoggedIn(): boolean {
|
||||
if (this.isKerberosConfigured()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (this.isECMProvider() || this.isALLProvider()) {
|
||||
if (!this.isOauth() && this.cookie.isEnabled() && !this.isRememberMeSet()) {
|
||||
return false;
|
||||
@@ -263,10 +286,6 @@ export class AuthenticationService {
|
||||
return false;
|
||||
}
|
||||
|
||||
isKerberosConfigured(): boolean {
|
||||
return this.appConfig.get<boolean>(AppConfigValues.AUTH_WITH_CREDENTIALS, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the ECM username.
|
||||
* @returns The ECM username
|
||||
|
Reference in New Issue
Block a user