diff --git a/lib/core/auth/src/authentication-interceptor/authentication.interceptor.spec.ts b/lib/core/auth/src/authentication-interceptor/authentication.interceptor.spec.ts index 18bb81aba64..07d0bdbe796 100644 --- a/lib/core/auth/src/authentication-interceptor/authentication.interceptor.spec.ts +++ b/lib/core/auth/src/authentication-interceptor/authentication.interceptor.spec.ts @@ -22,7 +22,7 @@ import { Authentication } from '../authentication'; import { AuthenticationInterceptor, SHOULD_ADD_AUTH_TOKEN } from './authentication.interceptor'; class MockAuthentication extends Authentication { - addTokenToHeader(httpHeaders: HttpHeaders): Observable { + addTokenToHeader(_: string, httpHeaders: HttpHeaders): Observable { return of(httpHeaders); } } diff --git a/lib/core/auth/src/authentication-interceptor/authentication.interceptor.ts b/lib/core/auth/src/authentication-interceptor/authentication.interceptor.ts index 94be3ade924..8e194eb40b8 100644 --- a/lib/core/auth/src/authentication-interceptor/authentication.interceptor.ts +++ b/lib/core/auth/src/authentication-interceptor/authentication.interceptor.ts @@ -43,7 +43,7 @@ export class AuthenticationInterceptor implements HttpInterceptor { Observable | HttpUserEvent> { if (req.context.get(SHOULD_ADD_AUTH_TOKEN)) { - return this.authService.addTokenToHeader(req.headers).pipe( + return this.authService.addTokenToHeader(req.url, req.headers).pipe( mergeMap((headersWithBearer) => { const headerWithContentType = this.appendJsonContentType(headersWithBearer); const kcReq = req.clone({ headers: headerWithContentType}); diff --git a/lib/core/auth/src/authentication.ts b/lib/core/auth/src/authentication.ts index 05bf0026823..87da959e1a8 100644 --- a/lib/core/auth/src/authentication.ts +++ b/lib/core/auth/src/authentication.ts @@ -19,5 +19,5 @@ import { HttpHeaders } from '@angular/common/http'; import { Observable } from 'rxjs'; export abstract class Authentication { - public abstract addTokenToHeader(headers: HttpHeaders): Observable; + public abstract addTokenToHeader(requestUrl: string, headers: HttpHeaders): Observable; } diff --git a/lib/core/src/lib/auth/basic-auth/basic-alfresco-auth.service.ts b/lib/core/src/lib/auth/basic-auth/basic-alfresco-auth.service.ts index bb5d6d156aa..e0f33d3cf79 100644 --- a/lib/core/src/lib/auth/basic-auth/basic-alfresco-auth.service.ts +++ b/lib/core/src/lib/auth/basic-auth/basic-alfresco-auth.service.ts @@ -21,7 +21,7 @@ import { Authentication } from '../interfaces/authentication.interface'; import { CookieService } from '../../common/services/cookie.service'; import { ContentAuth } from './content-auth'; import { ProcessAuth } from './process-auth'; -import { map } from 'rxjs/operators'; +import { catchError, map } from 'rxjs/operators'; import { from, Observable } from 'rxjs'; import { RedirectionModel } from '../models/redirection.model'; import { BaseAuthenticationService } from '../services/base-authentication.service'; @@ -97,7 +97,8 @@ export class BasicAlfrescoAuthService extends BaseAuthenticationService { type: this.appConfig.get(AppConfigValues.PROVIDERS), ticket: response }; - }) + }), + catchError((err) => this.handleError(err)) ); } @@ -337,8 +338,8 @@ export class BasicAlfrescoAuthService extends BaseAuthenticationService { private getTicketEcmBase64(requestUrl: string): string | null { let ticket = null; - const contextRootBpm = this.appConfig.get(AppConfigValues.CONTEXTROOTBPM); - const contextRoot = this.appConfig.get(AppConfigValues.CONTEXTROOTECM); + const contextRootBpm = this.appConfig.get(AppConfigValues.CONTEXTROOTBPM) || 'activiti-app'; + const contextRoot = this.appConfig.get(AppConfigValues.CONTEXTROOTECM) || 'alfresco'; if (contextRoot && requestUrl.indexOf(contextRoot) !== -1) { ticket = 'Basic ' + btoa(this.contentAuth.getToken()); diff --git a/lib/core/src/lib/auth/basic-auth/content-auth.ts b/lib/core/src/lib/auth/basic-auth/content-auth.ts index c8636585f0a..1a65001e139 100644 --- a/lib/core/src/lib/auth/basic-auth/content-auth.ts +++ b/lib/core/src/lib/auth/basic-auth/content-auth.ts @@ -109,13 +109,13 @@ export class ContentAuth { .catch((error) => { this.saveUsername(''); if (error.status === 401) { - this.adfHttpClient.emit('unauthorized'); + this.adfHttpClient.emit('unauthorized', error); this.onError.next('unauthorized'); } else if (error.status === 403) { - this.adfHttpClient.emit('forbidden'); + this.adfHttpClient.emit('forbidden', error); this.onError.next('forbidden'); } else { - this.adfHttpClient.emit('error'); + this.adfHttpClient.emit('error', error); this.onError.next('error'); } reject(error); diff --git a/lib/core/src/lib/auth/basic-auth/process-auth.ts b/lib/core/src/lib/auth/basic-auth/process-auth.ts index 8a1ff1cb78d..17618731c23 100644 --- a/lib/core/src/lib/auth/basic-auth/process-auth.ts +++ b/lib/core/src/lib/auth/basic-auth/process-auth.ts @@ -105,13 +105,13 @@ export class ProcessAuth { (error) => { this.saveUsername(''); if (error.status === 401) { - this.adfHttpClient.emit('unauthorized'); + this.adfHttpClient.emit('unauthorized', error); this.onError.next('unauthorized'); } else if (error.status === 403) { - this.adfHttpClient.emit('forbidden'); + this.adfHttpClient.emit('forbidden', error); this.onError.next('forbidden'); } else { - this.adfHttpClient.emit('error'); + this.adfHttpClient.emit('error', error); this.onError.next('error'); } reject(error);