diff --git a/src/app/core/auth/auth.effects.spec.ts b/src/app/core/auth/auth.effects.spec.ts index 7153c5ebbd..2e6ba917aa 100644 --- a/src/app/core/auth/auth.effects.spec.ts +++ b/src/app/core/auth/auth.effects.spec.ts @@ -221,7 +221,8 @@ describe('AuthEffects', () => { expect(authEffects.checkTokenCookie$).toBeObservable(expected); authEffects.checkTokenCookie$.subscribe(() => { - expect(authServiceStub.setExternalAuthStatus).toHaveBeenCalledWith(true); + expect(authServiceStub.setExternalAuthStatus).toHaveBeenCalled(); + expect(authServiceStub.isExternalAuthentication).toBeTrue(); expect((authEffects as any).authorizationsService.invalidateAuthorizationsRequestCache).toHaveBeenCalled(); }); }); diff --git a/src/app/core/auth/auth.service.ts b/src/app/core/auth/auth.service.ts index fae5872c89..6604936cde 100644 --- a/src/app/core/auth/auth.service.ts +++ b/src/app/core/auth/auth.service.ts @@ -156,10 +156,19 @@ export class AuthService { return this.store.pipe(select(isAuthenticatedLoaded)); } + /** + * Used to set the external authentication status when authenticating via an + * external authentication system (e.g. Shibboleth). + * @param external + */ public setExternalAuthStatus(external: boolean) { this.store.dispatch(new SetAuthCookieStatus(external)); } + /** + * Returns true if an external authentication system (e.g. Shibboleth) is being used + * for authentication. Returns false otherwise. + */ public isExternalAuthentication(): Observable { return this.store.pipe( select(getExternalAuthCookieStatus)); diff --git a/src/app/core/auth/selectors.ts b/src/app/core/auth/selectors.ts index 16246fb14c..aba739edf6 100644 --- a/src/app/core/auth/selectors.ts +++ b/src/app/core/auth/selectors.ts @@ -181,7 +181,7 @@ export const isAuthenticated = createSelector(getAuthState, _isAuthenticated); export const isAuthenticatedLoaded = createSelector(getAuthState, _isAuthenticatedLoaded); /** - * Returns the authentication cookie status. Expect to be ture when external authentication + * Returns the authentication cookie status. Expect to be true when external authentication * is used. * @function getExternalAuthCookieStatus * @param {AuthState} state diff --git a/src/app/shared/testing/auth-service.stub.ts b/src/app/shared/testing/auth-service.stub.ts index e5ae355658..7f3d040042 100644 --- a/src/app/shared/testing/auth-service.stub.ts +++ b/src/app/shared/testing/auth-service.stub.ts @@ -17,6 +17,7 @@ export class AuthServiceStub { token: AuthTokenInfo = new AuthTokenInfo('token_test'); impersonating: string; private _tokenExpired = false; + private _isExternalAuth = false; private redirectUrl; constructor() { @@ -123,11 +124,11 @@ export class AuthServiceStub { return; } setExternalAuthStatus(externalCookie: boolean) { - return; + this._isExternalAuth = externalCookie; } isExternalAuthentication(): Observable { - return; + return observableOf(this._isExternalAuth); } retrieveAuthMethodsFromAuthStatus(status: AuthStatus) { diff --git a/src/modules/app/browser-init.service.ts b/src/modules/app/browser-init.service.ts index 254406dc7e..61d57f10f9 100644 --- a/src/modules/app/browser-init.service.ts +++ b/src/modules/app/browser-init.service.ts @@ -56,7 +56,7 @@ export class BrowserInitService extends InitService { protected authService: AuthService, protected themeService: ThemeService, protected menuService: MenuService, - private rootDatatService: RootDataService + private rootDataService: RootDataService ) { super( store, @@ -153,7 +153,7 @@ export class BrowserInitService extends InitService { filter((externalAuth: boolean) => externalAuth) ).subscribe(() => { // Clear the transferState data. - this.rootDatatService.invalidateRootCache(); + this.rootDataService.invalidateRootCache(); this.authService.setExternalAuthStatus(false); } );