From bcc6daa39fd65defc9d0a2f5fb1a7cb10e4f6acb Mon Sep 17 00:00:00 2001 From: Julius Gruber Date: Thu, 8 Aug 2019 09:29:00 +0200 Subject: [PATCH] Added mock components for dynamic login components --- .../shibboleth.component.html | 0 .../shibboleth.component.scss | 0 .../shibboleth.component.spec.ts | 0 .../shibboleth.component.ts | 5 +-- src/app/core/auth/auth.interceptor.ts | 6 ++-- src/app/core/auth/models/auth-method.model.ts | 27 +++++++++++----- .../dynamic-test.component.html | 1 - .../dynamic-test.component.ts | 21 ------------- .../log-in/ip/dynamic-ip.component.html | 1 + .../dynamic-ip.component.scss} | 0 .../shared/log-in/ip/dynamic-ip.component.ts | 21 +++++++++++++ .../log-in/ldap/dynamic-ldap.component.html | 1 + .../log-in/ldap/dynamic-ldap.component.scss | 0 .../log-in/ldap/dynamic-ldap.component.ts | 21 +++++++++++++ .../log-in-container.component.scss | 0 .../log-in-container.component.ts | 31 +++++++++++-------- .../log-in/password/log-in.component.ts | 10 +----- .../dynamic-shibboleth.component.ts | 7 +---- .../log-in/x509/dynamic-x509.component.html | 1 + .../log-in/x509/dynamic-x509.component.scss | 0 .../log-in/x509/dynamic-x509.component.ts | 21 +++++++++++++ src/app/shared/shared.module.ts | 15 ++++++--- 22 files changed, 120 insertions(+), 69 deletions(-) rename src/app/+login-page/{shibboleth => shibbolethTargetPage}/shibboleth.component.html (100%) rename src/app/+login-page/{shibboleth => shibbolethTargetPage}/shibboleth.component.scss (100%) rename src/app/+login-page/{shibboleth => shibbolethTargetPage}/shibboleth.component.spec.ts (100%) rename src/app/+login-page/{shibboleth => shibbolethTargetPage}/shibboleth.component.ts (85%) delete mode 100644 src/app/shared/log-in/DynamicTestComponent/dynamic-test.component.html delete mode 100644 src/app/shared/log-in/DynamicTestComponent/dynamic-test.component.ts create mode 100644 src/app/shared/log-in/ip/dynamic-ip.component.html rename src/app/shared/log-in/{DynamicTestComponent/dynamic-test.component.scss => ip/dynamic-ip.component.scss} (100%) create mode 100644 src/app/shared/log-in/ip/dynamic-ip.component.ts create mode 100644 src/app/shared/log-in/ldap/dynamic-ldap.component.html create mode 100644 src/app/shared/log-in/ldap/dynamic-ldap.component.scss create mode 100644 src/app/shared/log-in/ldap/dynamic-ldap.component.ts create mode 100644 src/app/shared/log-in/log-in-container/log-in-container.component.scss create mode 100644 src/app/shared/log-in/x509/dynamic-x509.component.html create mode 100644 src/app/shared/log-in/x509/dynamic-x509.component.scss create mode 100644 src/app/shared/log-in/x509/dynamic-x509.component.ts diff --git a/src/app/+login-page/shibboleth/shibboleth.component.html b/src/app/+login-page/shibbolethTargetPage/shibboleth.component.html similarity index 100% rename from src/app/+login-page/shibboleth/shibboleth.component.html rename to src/app/+login-page/shibbolethTargetPage/shibboleth.component.html diff --git a/src/app/+login-page/shibboleth/shibboleth.component.scss b/src/app/+login-page/shibbolethTargetPage/shibboleth.component.scss similarity index 100% rename from src/app/+login-page/shibboleth/shibboleth.component.scss rename to src/app/+login-page/shibbolethTargetPage/shibboleth.component.scss diff --git a/src/app/+login-page/shibboleth/shibboleth.component.spec.ts b/src/app/+login-page/shibbolethTargetPage/shibboleth.component.spec.ts similarity index 100% rename from src/app/+login-page/shibboleth/shibboleth.component.spec.ts rename to src/app/+login-page/shibbolethTargetPage/shibboleth.component.spec.ts diff --git a/src/app/+login-page/shibboleth/shibboleth.component.ts b/src/app/+login-page/shibbolethTargetPage/shibboleth.component.ts similarity index 85% rename from src/app/+login-page/shibboleth/shibboleth.component.ts rename to src/app/+login-page/shibbolethTargetPage/shibboleth.component.ts index cfb4637e58..eb6b1681ff 100644 --- a/src/app/+login-page/shibboleth/shibboleth.component.ts +++ b/src/app/+login-page/shibbolethTargetPage/shibboleth.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit } from '@angular/core'; +import {Component, OnInit} from '@angular/core'; import {GetJWTafterShibbLoginAction} from '../../core/auth/auth.actions'; import {Store} from '@ngrx/store'; import {CoreState} from '../../core/core.reducers'; @@ -22,6 +22,7 @@ export class ShibbolethComponent implements OnInit { this.store.dispatch(new GetJWTafterShibbLoginAction()); } - constructor( private store: Store,) { } + constructor(private store: Store,) { + } } diff --git a/src/app/core/auth/auth.interceptor.ts b/src/app/core/auth/auth.interceptor.ts index 500f19704a..0e321573d9 100644 --- a/src/app/core/auth/auth.interceptor.ts +++ b/src/app/core/auth/auth.interceptor.ts @@ -32,8 +32,6 @@ 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) { } @@ -89,7 +87,7 @@ export class AuthInterceptor implements HttpInterceptor { const authMethod: AuthMethodModel = new AuthMethodModel(methodName); // check if the authentication method is shibboleth // if so the next part is the shibboleth location - // e.g part i: shibboleth realm="DSpace REST API", part i+1: location="/Shibboleth.sso/Login?target=https%3A%2F%2Flocalhost%3A8080" + // e.g part i: shibboleth realm="DSpace REST API", part i+1: location="/Shibboleth.sso/Login?target=https://serverUrl" if (methodName.includes('shibboleth')) { const location: string = this.parseShibbolethLocation(parts[+i + 1]); // +1: unaray + operator is necessaray because i is a string, the operator works like parseInt() // console.log('shib location: ', location); @@ -98,7 +96,7 @@ export class AuthInterceptor implements HttpInterceptor { authMethodModels.push(authMethod); } } - console.log('Array of AuthMethodModels: ', authMethodModels); + // console.log('Array of AuthMethodModels: ', authMethodModels); return authMethodModels; } diff --git a/src/app/core/auth/models/auth-method.model.ts b/src/app/core/auth/models/auth-method.model.ts index b886b3120d..c785506d1b 100644 --- a/src/app/core/auth/models/auth-method.model.ts +++ b/src/app/core/auth/models/auth-method.model.ts @@ -7,18 +7,27 @@ export class AuthMethodModel { this.authMethodName = authMethodName; this.location = location; switch (authMethodName) { - case 'password': { - this.authMethodConstant = AuthMethodConstants.PASSWORD; - break; - } - case 'shibboleth': { - this.authMethodConstant = AuthMethodConstants.SHIBBOLETH; + case 'ip': { + this.authMethodConstant = AuthMethodConstants.IP; break; } case 'ldap': { this.authMethodConstant = AuthMethodConstants.LDAP; break; } + case 'shibboleth': { + this.authMethodConstant = AuthMethodConstants.SHIBBOLETH; + break; + } + case 'x509': { + this.authMethodConstant = AuthMethodConstants.X509; + break; + } + case 'password': { + this.authMethodConstant = AuthMethodConstants.PASSWORD; + break; + } + default: { break; } @@ -27,7 +36,9 @@ export class AuthMethodModel { } export enum AuthMethodConstants { - PASSWORD, + IP, + LDAP, SHIBBOLETH, - LDAP + X509, + PASSWORD, } diff --git a/src/app/shared/log-in/DynamicTestComponent/dynamic-test.component.html b/src/app/shared/log-in/DynamicTestComponent/dynamic-test.component.html deleted file mode 100644 index c8a7eaef7d..0000000000 --- a/src/app/shared/log-in/DynamicTestComponent/dynamic-test.component.html +++ /dev/null @@ -1 +0,0 @@ -

This is the DynamicTestComponent

diff --git a/src/app/shared/log-in/DynamicTestComponent/dynamic-test.component.ts b/src/app/shared/log-in/DynamicTestComponent/dynamic-test.component.ts deleted file mode 100644 index 6b328c4376..0000000000 --- a/src/app/shared/log-in/DynamicTestComponent/dynamic-test.component.ts +++ /dev/null @@ -1,21 +0,0 @@ -/** - * /users/sign-in - * @class LogInComponent - */ -import {Component, OnInit} from '@angular/core'; - -@Component({ - selector: 'ds-dynamic-test', - templateUrl: './dynamic-test.component.html', - styleUrls: ['./dynamic-test.component.scss'], - -}) -export class DynamicTestComponent { - - /** - * @constructor - */ - constructor() { - // console.log('constructor of DynamicTestComponent called'); - } -} diff --git a/src/app/shared/log-in/ip/dynamic-ip.component.html b/src/app/shared/log-in/ip/dynamic-ip.component.html new file mode 100644 index 0000000000..413a8d71ba --- /dev/null +++ b/src/app/shared/log-in/ip/dynamic-ip.component.html @@ -0,0 +1 @@ +
IP based login component - to be implemented
diff --git a/src/app/shared/log-in/DynamicTestComponent/dynamic-test.component.scss b/src/app/shared/log-in/ip/dynamic-ip.component.scss similarity index 100% rename from src/app/shared/log-in/DynamicTestComponent/dynamic-test.component.scss rename to src/app/shared/log-in/ip/dynamic-ip.component.scss diff --git a/src/app/shared/log-in/ip/dynamic-ip.component.ts b/src/app/shared/log-in/ip/dynamic-ip.component.ts new file mode 100644 index 0000000000..9b189a6e05 --- /dev/null +++ b/src/app/shared/log-in/ip/dynamic-ip.component.ts @@ -0,0 +1,21 @@ +/** + * /users/sign-in + * @class LogInComponent + */ +import {Component, OnInit} from '@angular/core'; + +@Component({ + selector: 'ds-dynamic-ip', + templateUrl: './dynamic-ip.component.html', + styleUrls: ['./dynamic-ip.component.scss'], + +}) +export class DynamicIpComponent { + + /** + * @constructor + */ + constructor() { + // console.log('constructor of DynamicLdapComponent called'); + } +} diff --git a/src/app/shared/log-in/ldap/dynamic-ldap.component.html b/src/app/shared/log-in/ldap/dynamic-ldap.component.html new file mode 100644 index 0000000000..c00ba0eaf4 --- /dev/null +++ b/src/app/shared/log-in/ldap/dynamic-ldap.component.html @@ -0,0 +1 @@ +
LDAP login component - to be implemented
diff --git a/src/app/shared/log-in/ldap/dynamic-ldap.component.scss b/src/app/shared/log-in/ldap/dynamic-ldap.component.scss new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/app/shared/log-in/ldap/dynamic-ldap.component.ts b/src/app/shared/log-in/ldap/dynamic-ldap.component.ts new file mode 100644 index 0000000000..339b7cee92 --- /dev/null +++ b/src/app/shared/log-in/ldap/dynamic-ldap.component.ts @@ -0,0 +1,21 @@ +/** + * /users/sign-in + * @class LogInComponent + */ +import {Component, OnInit} from '@angular/core'; + +@Component({ + selector: 'ds-dynamic-ldap', + templateUrl: './dynamic-ldap.component.html', + styleUrls: ['./dynamic-ldap.component.scss'], + +}) +export class DynamicLdapComponent { + + /** + * @constructor + */ + constructor() { + // console.log('constructor of DynamicLdapComponent called'); + } +} diff --git a/src/app/shared/log-in/log-in-container/log-in-container.component.scss b/src/app/shared/log-in/log-in-container/log-in-container.component.scss new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/app/shared/log-in/log-in-container/log-in-container.component.ts b/src/app/shared/log-in/log-in-container/log-in-container.component.ts index e03b75d72c..4ec9b79840 100644 --- a/src/app/shared/log-in/log-in-container/log-in-container.component.ts +++ b/src/app/shared/log-in/log-in-container/log-in-container.component.ts @@ -1,21 +1,21 @@ -import {Component, Injector, OnDestroy, OnInit, ReflectiveInjector} from '@angular/core'; -import {AuthState} from '../../../core/auth/auth.reducer'; +import {Component, Injector, OnDestroy, OnInit} from '@angular/core'; import {Store} from '@ngrx/store'; -import {DynamicTestComponent} from '../DynamicTestComponent/dynamic-test.component'; import {LogInComponent} from '../password/log-in.component'; import {DynamicShibbolethComponent} from '../shibboleth/dynamic-shibboleth.component'; import {getAuthenticationMethods} from '../../../core/auth/selectors'; -import {map, tap} from 'rxjs/operators'; +import {map} from 'rxjs/operators'; import {AppState} from '../../../app.reducer'; import {Observable} from 'rxjs'; import {DynamicLoginMethod} from './log-in-container.model'; -import {AuthMethodConstants, AuthMethodModel} from '../../../core/auth/models/auth-method.model'; -import {ShibbolethComponent} from '../../../+login-page/shibboleth/shibboleth.component'; +import {AuthMethodConstants} from '../../../core/auth/models/auth-method.model'; +import {DynamicLdapComponent} from '../ldap/dynamic-ldap.component'; +import {DynamicX509Component} from '../x509/dynamic-x509.component'; +import {DynamicIpComponent} from '../ip/dynamic-ip.component'; @Component({ selector: 'ds-log-in-container', templateUrl: './log-in-container.component.html', - // styleUrls: ['./log-in.component.scss'], + styleUrls: ['./log-in-container.component.scss'], }) export class LogInContainerComponent implements OnDestroy, OnInit { @@ -50,8 +50,8 @@ export class LogInContainerComponent implements OnDestroy, OnInit { this.objectInjector = Injector.create({ providers: [ {provide: 'shibbolethUrlProvider', useFactory: () => (this.shibbolethUrl), deps: []}, - // {provide: 'sectionDataProvider', useFactory: () => (this.sectionData), deps: []}, - // {provide: 'submissionIdProvider', useFactory: () => (this.submissionId), deps: []}, + // if other authentication methods need further data to work add a provider here e.g + // {provide: 'otherDataProvider', useFactory: () => (this.otherData), deps: []}, ], parent: this.injector }); @@ -67,6 +67,15 @@ export class LogInContainerComponent implements OnDestroy, OnInit { this.shibbolethUrl = 'https://fis.tiss.tuwien.ac.at/Shibboleth.sso/Login?target=https://fis.tiss.tuwien.ac.at/shibboleth'; return new DynamicLoginMethod(authMethod.authMethodName, DynamicShibbolethComponent, authMethod.location) break; + case AuthMethodConstants.LDAP: + return new DynamicLoginMethod(authMethod.authMethodName, DynamicLdapComponent) + break; + case AuthMethodConstants.IP: + return new DynamicLoginMethod(authMethod.authMethodName, DynamicIpComponent) + break; + case AuthMethodConstants.X509: + return new DynamicLoginMethod(authMethod.authMethodName, DynamicX509Component) + break; default: break; } @@ -83,10 +92,6 @@ export class LogInContainerComponent implements OnDestroy, OnInit { label: 'PasswordComponent', component: LogInComponent }, - { - label: 'TestComponent', - component: DynamicTestComponent - }, { label: 'ShibbolethComponent', component: DynamicShibbolethComponent diff --git a/src/app/shared/log-in/password/log-in.component.ts b/src/app/shared/log-in/password/log-in.component.ts index 07dc525235..310e11ad2b 100644 --- a/src/app/shared/log-in/password/log-in.component.ts +++ b/src/app/shared/log-in/password/log-in.component.ts @@ -20,7 +20,6 @@ import {CoreState} from '../../../core/core.reducers'; import {isNotEmpty} from '../../empty.util'; import {fadeOut} from '../../animations/fade'; import {AuthService} from '../../../core/auth/auth.service'; -import {DynamicTestComponent} from '../DynamicTestComponent/dynamic-test.component'; /** * /users/sign-in @@ -82,7 +81,7 @@ export class LogInComponent implements OnDestroy, OnInit { */ private alive = true; - dynamicLoginMethods: any; + /** * @constructor @@ -103,13 +102,6 @@ export class LogInComponent implements OnDestroy, OnInit { */ public ngOnInit() { - this.dynamicLoginMethods = this.dynamicLoginMethods = [ - { - label: 'TestComponent', - component: DynamicTestComponent - } - ]; - // set isAuthenticated this.isAuthenticated = this.store.pipe(select(isAuthenticated)); diff --git a/src/app/shared/log-in/shibboleth/dynamic-shibboleth.component.ts b/src/app/shared/log-in/shibboleth/dynamic-shibboleth.component.ts index a6369f09c3..094fdcffca 100644 --- a/src/app/shared/log-in/shibboleth/dynamic-shibboleth.component.ts +++ b/src/app/shared/log-in/shibboleth/dynamic-shibboleth.component.ts @@ -1,10 +1,5 @@ -/** - * /users/sign-in - * @class LogInComponent - */ + import {Component, Inject, Input, OnInit} from '@angular/core'; -import {InputDecorator} from '@angular/core/src/metadata/directives'; -import {HttpClient} from '@angular/common/http'; @Component({ selector: 'ds-dynamic-shibboleth', diff --git a/src/app/shared/log-in/x509/dynamic-x509.component.html b/src/app/shared/log-in/x509/dynamic-x509.component.html new file mode 100644 index 0000000000..3d0d680101 --- /dev/null +++ b/src/app/shared/log-in/x509/dynamic-x509.component.html @@ -0,0 +1 @@ +
X509 login component - to be implemented
diff --git a/src/app/shared/log-in/x509/dynamic-x509.component.scss b/src/app/shared/log-in/x509/dynamic-x509.component.scss new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/app/shared/log-in/x509/dynamic-x509.component.ts b/src/app/shared/log-in/x509/dynamic-x509.component.ts new file mode 100644 index 0000000000..d30fea58d8 --- /dev/null +++ b/src/app/shared/log-in/x509/dynamic-x509.component.ts @@ -0,0 +1,21 @@ +/** + * /users/sign-in + * @class LogInComponent + */ +import {Component, OnInit} from '@angular/core'; + +@Component({ + selector: 'ds-dynamic-x509', + templateUrl: './dynamic-x509.component.html', + styleUrls: ['./dynamic-x509.component.scss'], + +}) +export class DynamicX509Component { + + /** + * @constructor + */ + constructor() { + // console.log('constructor of DynamicLdapComponent called'); + } +} diff --git a/src/app/shared/shared.module.ts b/src/app/shared/shared.module.ts index 3d0fe6c2b4..e100ecc70a 100644 --- a/src/app/shared/shared.module.ts +++ b/src/app/shared/shared.module.ts @@ -138,10 +138,12 @@ import { RoleDirective } from './roles/role.directive'; import { UserMenuComponent } from './auth-nav-menu/user-menu/user-menu.component'; import { ClaimedTaskActionsReturnToPoolComponent } from './mydspace-actions/claimed-task/return-to-pool/claimed-task-actions-return-to-pool.component'; import { ItemDetailPreviewFieldComponent } from './object-detail/my-dspace-result-detail-element/item-detail-preview/item-detail-preview-field/item-detail-preview-field.component'; -import {DynamicTestComponent} from './log-in/DynamicTestComponent/dynamic-test.component'; import {LogInContainerComponent} from './log-in/log-in-container/log-in-container.component'; import {s} from '@angular/core/src/render3'; import {DynamicShibbolethComponent} from './log-in/shibboleth/dynamic-shibboleth.component'; +import {DynamicLdapComponent} from './log-in/ldap/dynamic-ldap.component'; +import {DynamicIpComponent} from './log-in/ip/dynamic-ip.component'; +import {DynamicX509Component} from './log-in/x509/dynamic-x509.component'; const MODULES = [ // Do NOT include UniversalModule, HttpModule, or JsonpModule here @@ -263,7 +265,9 @@ const COMPONENTS = [ ItemTypeSwitcherComponent, BrowseByComponent, LogInContainerComponent, - DynamicShibbolethComponent + DynamicShibbolethComponent, + DynamicLdapComponent, + DynamicIpComponent ]; const ENTRY_COMPONENTS = [ @@ -307,10 +311,11 @@ const ENTRY_COMPONENTS = [ PlainTextMetadataListElementComponent, ItemMetadataListElementComponent, MetadataRepresentationListElementComponent, - DynamicTestComponent, + DynamicLdapComponent, LogInComponent, - DynamicShibbolethComponent - + DynamicShibbolethComponent, + DynamicIpComponent, + DynamicX509Component ]; const SHARED_ITEM_PAGE_COMPONENTS = [