Basic implmentation of the dynamic rendering of Authentication Methods

This commit is contained in:
Julius Gruber
2019-09-04 16:19:59 +02:00
parent c428b1deef
commit 6167012e32
5 changed files with 18 additions and 17 deletions

View File

@@ -62,17 +62,17 @@ export class AuthEffects {
* Authenticate user.
* @method authenticate
*/
/* @Effect()
@Effect()
public shibbolethAuthenticate$: Observable<Action> = this.actions$.pipe(
ofType(AuthActionTypes.START_SHIBBOLETH_AUTHENTICATION),
switchMap((action: StartShibbolethAuthenticationAction) => {
return this.authService.authenticate(action.payload.location).pipe(
return this.authService.shibbolethAuthenticate(action.payload.location).pipe(
take(1),
map((response: AuthStatus) => new AuthenticationSuccessAction(response.token)),
catchError((error) => observableOf(new AuthenticationErrorAction(error)))
);
})
);*/
);
/**
* Shib Login.

View File

@@ -115,6 +115,19 @@ export class AuthService {
}
shibbolethAuthenticate(location: string) {
// implement a call to the backend here
console.log('location: ', location);
return this.authRequestService.postToEndpoint('login').pipe(
map((status: AuthStatus) => {
if (status.authenticated) {
return status;
} else {
throw(new Error('Shibboleth login failed'));
}
}))
}
public startShibbAuth(): Observable<AuthStatus> {
console.log('startShibAuth() was called');
// Attempt authenticating the user after the shibboleth/saml response reached the backend

View File

@@ -1,6 +1,7 @@
import { AuthMethodType } from './authMethods-type';
const authMethodsMap = new Map();
export function renderAuthMethodFor(authMethodType: AuthMethodType) {
return function decorator(objectElement: any) {
if (!objectElement) {

View File

@@ -1,13 +1,8 @@
import { Component, ContentChild, Injector, Input, OnInit, ViewChild, ViewChildren } from '@angular/core';
import { rendersAuthMethodType } from '../authMethods-decorator';
import { AuthMethodModel } from '../../../core/auth/models/auth-method.model';
import { getAuthenticationMethods, isAuthenticated, isAuthenticationLoading } from '../../../core/auth/selectors';
import { select, Store } from '@ngrx/store';
import { AppState } from '../../../app.reducer';
import { Observable } from 'rxjs';
import { AuthMethodType } from '../authMethods-type';
import { CoreState } from '../../../core/core.reducers';
import { ShibbolethComponent } from '../../../+login-page/shibbolethTargetPage/shibboleth.component';
/**
* This component represents a section that contains the submission license form.
@@ -45,9 +40,6 @@ export class LoginContainerComponent implements OnInit {
],
parent: this.injector
});
}
/**
@@ -57,9 +49,4 @@ export class LoginContainerComponent implements OnInit {
return rendersAuthMethodType(this.authMethodModel.authMethodType)
}
startShibbolethAuthentication($event) {
console.log('startShibbolethAuthentication() was called with event: ', $event);
// this.store.dispatch(new ShibbolethAuthenticateAction());
}
}

View File

@@ -49,7 +49,7 @@ export class DynamicShibbolethComponent implements OnInit {
}
ngOnInit(): void {
console.log('injectedAuthMethodModel', this.injectedAuthMethodModel);
// console.log('injectedAuthMethodModel', this.injectedAuthMethodModel);
// set formGroup
this.shibbForm = this.formBuilder.group({
shibbButton: [''],