Added mock components for dynamic login components

This commit is contained in:
Julius Gruber
2019-08-08 09:29:00 +02:00
parent 68968ca70a
commit bcc6daa39f
22 changed files with 120 additions and 69 deletions

View File

@@ -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<CoreState>,) { }
constructor(private store: Store<CoreState>,) {
}
}

View File

@@ -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<AppState>) {
}
@@ -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;
}

View File

@@ -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,
}

View File

@@ -1 +0,0 @@
<h1>This is the DynamicTestComponent</h1>

View File

@@ -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');
}
}

View File

@@ -0,0 +1 @@
<div>IP based login component - to be implemented</div>

View File

@@ -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');
}
}

View File

@@ -0,0 +1 @@
<div>LDAP login component - to be implemented</div>

View File

@@ -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');
}
}

View File

@@ -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

View File

@@ -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));

View File

@@ -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',

View File

@@ -0,0 +1 @@
<div>X509 login component - to be implemented</div>

View File

@@ -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');
}
}

View File

@@ -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 = [