From d25f12590db0f291916d2479b1a21828144f8086 Mon Sep 17 00:00:00 2001 From: Julius Gruber Date: Mon, 5 Aug 2019 09:00:13 +0200 Subject: [PATCH] Branch upadate --- src/app/app-routing.module.ts | 6 +++--- src/app/core/auth/auth.interceptor.ts | 20 ++++++++++++++++--- src/app/core/auth/models/auth-method.model.ts | 4 ++++ src/app/core/auth/models/auth-status.model.ts | 4 ++++ .../models/normalized-auth-status.model.ts | 2 ++ 5 files changed, 30 insertions(+), 6 deletions(-) create mode 100644 src/app/core/auth/models/auth-method.model.ts diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index 1ba62acce5..9611e98325 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -47,10 +47,10 @@ export function getCommunityModulePath() { path: 'workspaceitems', loadChildren: './+workspaceitems-edit-page/workspaceitems-edit-page.module#WorkspaceitemsEditPageModule' }, - /* { + { path: 'workflowitems', - loadChildren: './+workflowitems-edit-page/workflowitems-edit-page.module#WorkflowitemsEditPageModule' - },*/ + loadChildren: './+workflowitems-edit-page/workflowitems-edit-page.module#WorkflowItemsEditPageModule' // WorkflowItemsEditPageModule + }, {path: '**', pathMatch: 'full', component: PageNotFoundComponent}, ]) ], diff --git a/src/app/core/auth/auth.interceptor.ts b/src/app/core/auth/auth.interceptor.ts index 994d39f33a..5803f0a4c8 100644 --- a/src/app/core/auth/auth.interceptor.ts +++ b/src/app/core/auth/auth.interceptor.ts @@ -22,6 +22,7 @@ import {RedirectWhenTokenExpiredAction, RefreshTokenAction} from './auth.actions import {Store} from '@ngrx/store'; import {Router} from '@angular/router'; import {AuthError} from './models/auth-error.model'; +import {AuthMethodModel} from './models/auth-method.model'; @Injectable() export class AuthInterceptor implements HttpInterceptor { @@ -31,6 +32,8 @@ export class AuthInterceptor implements HttpInterceptor { // we're creating a refresh token request list protected refreshTokenRequestUrls = []; + private + constructor(private inj: Injector, private router: Router, private store: Store) { } @@ -62,11 +65,22 @@ export class AuthInterceptor implements HttpInterceptor { return http.url && http.url.endsWith('/authn/logout'); } - private makeAuthStatusObject(authenticated: boolean, accessToken?: string, error?: string, location?: string): AuthStatus { + private parseAuthMethodsfromHeaders(headers: HttpHeaders): AuthMethodModel[] { + console.log('parseAuthMethodsfromHeaders(): ', headers); + // errorHeaders + return []; + } + + private makeAuthStatusObject(authenticated: boolean, accessToken?: string, error?: string, location?: string, httpHeaders?: HttpHeaders, ): AuthStatus { const authStatus = new AuthStatus(); + + const authMethods: AuthMethodModel[] = this.parseAuthMethodsfromHeaders(httpHeaders); authStatus.id = null; + authStatus.okay = true; - authStatus.ssoLoginUrl = location; // this line was added while developing shibboleth login + authStatus.authMethods = authMethods; + + authStatus.ssoLoginUrl = location; // this line was added while developing shibboleth login 1.0 - remove it if (authenticated) { authStatus.authenticated = true; authStatus.token = new AuthTokenInfo(accessToken); @@ -179,7 +193,7 @@ export class AuthInterceptor implements HttpInterceptor { } // Create a new HttpResponse and return it, so it can be handle properly by AuthService. const authResponse = new HttpResponse({ - body: this.makeAuthStatusObject(false, null, error.error, location), + body: this.makeAuthStatusObject(false, null, error.error, location, error.headers ), headers: error.headers, status: error.status, statusText: error.statusText, diff --git a/src/app/core/auth/models/auth-method.model.ts b/src/app/core/auth/models/auth-method.model.ts new file mode 100644 index 0000000000..f27368f68d --- /dev/null +++ b/src/app/core/auth/models/auth-method.model.ts @@ -0,0 +1,4 @@ +export class AuthMethodModel { + authMethodName: string; + location?: string; +} diff --git a/src/app/core/auth/models/auth-status.model.ts b/src/app/core/auth/models/auth-status.model.ts index 19b69479f4..5299b5978b 100644 --- a/src/app/core/auth/models/auth-status.model.ts +++ b/src/app/core/auth/models/auth-status.model.ts @@ -5,6 +5,7 @@ import { RemoteData } from '../../data/remote-data'; import { Observable } from 'rxjs'; import { CacheableObject } from '../../cache/object-cache.reducer'; import { ResourceType } from '../../shared/resource-type'; +import {AuthMethodModel} from './auth-method.model'; /** * Object that represents the authenticated status of a user @@ -53,4 +54,7 @@ export class AuthStatus implements CacheableObject { self: string; ssoLoginUrl: string; + + authMethods: AuthMethodModel[]; + } diff --git a/src/app/core/auth/models/normalized-auth-status.model.ts b/src/app/core/auth/models/normalized-auth-status.model.ts index 3892bee408..672cd5d062 100644 --- a/src/app/core/auth/models/normalized-auth-status.model.ts +++ b/src/app/core/auth/models/normalized-auth-status.model.ts @@ -4,6 +4,7 @@ import { mapsTo, relationship } from '../../cache/builders/build-decorators'; import { NormalizedObject } from '../../cache/models/normalized-object.model'; import { IDToUUIDSerializer } from '../../cache/id-to-uuid-serializer'; import { EPerson } from '../../eperson/models/eperson.model'; +import {AuthMethodModel} from './auth-method.model'; @mapsTo(AuthStatus) @inheritSerialization(NormalizedObject) @@ -38,4 +39,5 @@ export class NormalizedAuthStatus extends NormalizedObject { @relationship(EPerson, false) @autoserialize eperson: string; + }