Branch change commit

This commit is contained in:
Julius Gruber
2019-06-03 15:48:05 +02:00
parent 086579b7f7
commit 73c046974b
3 changed files with 12 additions and 2 deletions

View File

@@ -50,9 +50,12 @@ export class AuthRequestService {
} }
public getRequest(method: string, options?: HttpOptions): Observable<any> { public getRequest(method: string, options?: HttpOptions): Observable<any> {
console.log('auth.request getRequest() was called');
return this.halService.getEndpoint(this.linkName).pipe( return this.halService.getEndpoint(this.linkName).pipe(
filter((href: string) => isNotEmpty(href)), filter((href: string) => isNotEmpty(href)),
tap((href) => console.log('auth-request.service getRequest()',href)),
map((endpointURL) => this.getEndpointByMethod(endpointURL, method)), map((endpointURL) => this.getEndpointByMethod(endpointURL, method)),
tap((whatsThis) => console.log('whatsThis: ', whatsThis )),
distinctUntilChanged(), distinctUntilChanged(),
map((endpointURL: string) => new AuthGetRequest(this.requestService.generateRequestId(), endpointURL, options)), map((endpointURL: string) => new AuthGetRequest(this.requestService.generateRequestId(), endpointURL, options)),
tap((request: GetRequest) => this.requestService.configure(request, true)), tap((request: GetRequest) => this.requestService.configure(request, true)),

View File

@@ -21,6 +21,7 @@ import { isNotEmpty, isUndefined, isNotNull } from '../../shared/empty.util';
import { RedirectWhenTokenExpiredAction, RefreshTokenAction } from './auth.actions'; import { RedirectWhenTokenExpiredAction, RefreshTokenAction } from './auth.actions';
import { Store } from '@ngrx/store'; import { Store } from '@ngrx/store';
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import {AuthError} from './models/auth-error.model';
@Injectable() @Injectable()
export class AuthInterceptor implements HttpInterceptor { export class AuthInterceptor implements HttpInterceptor {
@@ -56,11 +57,11 @@ export class AuthInterceptor implements HttpInterceptor {
return http.url && http.url.endsWith('/authn/logout'); return http.url && http.url.endsWith('/authn/logout');
} }
private makeAuthStatusObject(authenticated:boolean, accessToken?: string, error?: string, location?): AuthStatus { private makeAuthStatusObject(authenticated:boolean, accessToken?: string, error?: string, location?: string): AuthStatus {
const authStatus = new AuthStatus(); const authStatus = new AuthStatus();
authStatus.id = null; authStatus.id = null;
authStatus.okay = true; authStatus.okay = true;
authStatus.ssoLoginUrl = location; // this line added while developing shibboleth dev authStatus.ssoLoginUrl = location; // this line was added while developing shibboleth dev
if (authenticated) { if (authenticated) {
authStatus.authenticated = true; authStatus.authenticated = true;
authStatus.token = new AuthTokenInfo(accessToken); authStatus.token = new AuthTokenInfo(accessToken);
@@ -128,13 +129,17 @@ export class AuthInterceptor implements HttpInterceptor {
} }
}), }),
catchError((error, caught) => { catchError((error, caught) => {
console.log('catchError operator in auth.interceptor was triggered');
// Intercept an error response // Intercept an error response
if (error instanceof HttpErrorResponse) { if (error instanceof HttpErrorResponse) {
// Checks if is a response from a request to an authentication endpoint // Checks if is a response from a request to an authentication endpoint
if (this.isAuthRequest(error)) { if (this.isAuthRequest(error)) {
console.log('catchError isAuthRequest=true');
// clean eventually refresh Requests list // clean eventually refresh Requests list
this.refreshTokenRequestUrls = []; this.refreshTokenRequestUrls = [];
// console.log('error: ', error);
const location = error.headers.get('Location');// this line added while shibboleth dev const location = error.headers.get('Location');// this line added while shibboleth dev
console.log('error.headers.get("Location"): ', location);
// Create a new HttpResponse and return it, so it can be handle properly by AuthService. // Create a new HttpResponse and return it, so it can be handle properly by AuthService.
const authResponse = new HttpResponse({ const authResponse = new HttpResponse({
body: this.makeAuthStatusObject(false, null, error.error, location), body: this.makeAuthStatusObject(false, null, error.error, location),

View File

@@ -202,6 +202,7 @@ export class AuthService {
* @returns {User} * @returns {User}
*/ */
public retrieveAuthMethods(): Observable<string> { public retrieveAuthMethods(): Observable<string> {
console.log('auth.service retrieveAuthMethods() was called');
return this.authRequestService.getRequest('login').pipe( return this.authRequestService.getRequest('login').pipe(
map((status: AuthStatus) => { map((status: AuthStatus) => {
let url = ''; let url = '';
@@ -214,6 +215,7 @@ export class AuthService {
} }
private parseSSOLocation(url: string): string { private parseSSOLocation(url: string): string {
console.log('auth.service parseSSOLocation was called');
const parseUrl = decodeURIComponent(url); const parseUrl = decodeURIComponent(url);
// const urlTree: UrlTree = this.router.parseUrl(url); // const urlTree: UrlTree = this.router.parseUrl(url);
// this.router.parseUrl(url); // this.router.parseUrl(url);