AAE-37746 logout on session_error during session checks

This commit is contained in:
alep85
2025-10-28 15:33:42 +01:00
parent 4e349fb905
commit 8d8f4a0ef0
2 changed files with 17 additions and 1 deletions
@@ -273,6 +273,21 @@ describe('RedirectAuthService', () => {
expect(oauthServiceSpy.logOut).toHaveBeenCalledTimes(1);
});
it('should logout user if sessionChecksEnabled is true and event type session_error is emitted', async () => {
const mockTimeSync = { outOfSync: false } as TimeSync;
timeSyncServiceSpy.checkTimeSync.and.returnValue(of(mockTimeSync));
ensureDiscoveryDocumentSpy.and.resolveTo(true);
authConfigSpy.sessionChecksEnabled = true;
await service.init();
oauthEvents$.next({ type: 'session_error' } as OAuthEvent);
expect(oauthServiceSpy.logOut).toHaveBeenCalledTimes(1);
});
it('should NOT logout user if login success', async () => {
ensureDiscoveryDocumentSpy.and.resolveTo(true);
@@ -339,7 +339,8 @@ export class RedirectAuthService extends AuthService {
this.oauthService.tokenValidationHandler = new JwksValidationHandler();
if (config.sessionChecksEnabled) {
this.oauthService.events.pipe(filter((event) => event.type === 'session_terminated')).subscribe(() => {
const sessionErrorTypesToPerformLogout = ['session_terminated', 'session_error'];
this.oauthService.events.pipe(filter((event) => sessionErrorTypesToPerformLogout.includes(event.type))).subscribe(() => {
this.oauthService.logOut();
});
}