From 549d268629b9dd483edb5b12020b83c0d1a12a40 Mon Sep 17 00:00:00 2001 From: Amedeo Lepore Date: Mon, 21 Oct 2024 11:33:09 +0200 Subject: [PATCH] AAE-26163 Fix infinite loop when authentication error event occured (#10272) * AAE-26163 Logout user after 3 login attempts failed, avoiding infinite loop when an authentication error occured, like when a user machine clock is significantly out of sync * AAE-26163 Wait to discovery document to be loaded and user not authenticated to perform a ssoLogin, logout user if login fails after 3 attempts * AAE-26163 Fix missed id_token_hint invoking logout when a login error occured due to a clock significantly out of sync * AAE-26163 Add fake observable to unit test * AAE-26163 Show oauth event logs if showDebugInformation is enabled, remove auth items if access token is not valid * AAE-26163 Improve tryLogin error message * AAE-26163 Check if token has expired to fix case when user access the application after the token is expired and with a clock significantly out of sync * AAE-26163 Test logout when clock is out of sync * AAE-26163 Create a service to check if local machine time is out of sync * AAE-26163 Update oauthErrorEvent$ and combinedOAuthErrorsStream$ to return errors * AAE-26163 Output error within combined oauth error event subscription * AAE-26163 Fix lint problems * AAE-26163 Logout user when token refresh error happens for the second time, if the token is not refreshed properly after first refresh error * AAE-26163 Logout user once an oauth error event occur due to clock out of sync * AAE-26163 Fix retry login error message if the OAuthErrorEvent doesn t return reason * AAE-26163 Fix the issue where the logout API call is canceled by the authorize call when login fails due to clock synchronization problems, causing an infinite loop. * remove console.log * AAE-26163 Fix retry login error message if the OAuthErrorEvent reason is an empty object --- lib/core/src/lib/auth/oidc/auth.module.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/core/src/lib/auth/oidc/auth.module.ts b/lib/core/src/lib/auth/oidc/auth.module.ts index f3197306db5..a510faf669d 100644 --- a/lib/core/src/lib/auth/oidc/auth.module.ts +++ b/lib/core/src/lib/auth/oidc/auth.module.ts @@ -25,6 +25,8 @@ import { AuthRoutingModule } from './auth-routing.module'; import { AuthService } from './auth.service'; import { RedirectAuthService } from './redirect-auth.service'; import { AuthenticationConfirmationComponent } from './view/authentication-confirmation/authentication-confirmation.component'; +import { HTTP_INTERCEPTORS } from '@angular/common/http'; +import { TokenInterceptor } from './token.interceptor'; /** * Create a Login Factory function @@ -53,6 +55,11 @@ export function loginFactory(redirectService: RedirectAuthService): () => Promis useFactory: loginFactory, deps: [RedirectAuthService], multi: true + }, + { + provide: HTTP_INTERCEPTORS, + useClass: TokenInterceptor, + multi: true } ] })