Make authstorage configurable

This commit is contained in:
Willem Dantuma
2020-01-22 11:33:33 +01:00
parent e8845a092a
commit 3f27662e3f
5 changed files with 51 additions and 8 deletions

View File

@@ -1,12 +1,13 @@
import { Injector } from '@angular/core';
import { Location} from '@angular/common';
import { Router,UrlSerializer } from '@angular/router';
import { AuthConfig, OAuthService, JwksValidationHandler, OAuthErrorEvent } from 'angular-oauth2-oidc';
import { AuthConfig, OAuthService, JwksValidationHandler, OAuthErrorEvent, OAuthStorage } from 'angular-oauth2-oidc';
import { AppConfig } from "./app.config";
import { IAuthconfigFactory } from './authconfigFactory';
export function appConfigFactory(injector:Injector, appConfig: AppConfig, oauthService: OAuthService, authconfigFactory:IAuthconfigFactory): () => Promise<any> {
export function appConfigFactory(injector:Injector, appConfig: AppConfig, oauthService: OAuthService, authconfigFactory:IAuthconfigFactory,authStorage:OAuthStorage): () => Promise<any> {
return (): Promise<any> => {
return appConfig.load().then(() => {
oauthService.events.subscribe((event) => {
@@ -22,7 +23,7 @@ export function appConfigFactory(injector:Injector, appConfig: AppConfig, oauthS
}
});
oauthService.configure(authconfigFactory.getAuthConfig(appConfig));
oauthService.setStorage(localStorage);
oauthService.setStorage(authStorage);
oauthService.tokenValidationHandler = new JwksValidationHandler();
oauthService.tokenValidationHandler.validateAtHash = function () {
return new Promise<boolean>((res) => { res(true); })