1 year ago
#156063
Lisa
Angular app integrated with key cloak is redirecting to login page ONLY ON page refresh
I have an Angular app, which is configured with key cloak Authentication. Once every 30minutes, the cookie/session set by key cloak gets expired . As per the default behavior, the app is redirecting to login page when the user refreshes the app manually.
- But I wanted it some thing like whenever the token get expired , redirect the current session to key cloak login page. (this should happen automatically, i.e., even with out user manual refreshes the page.)
- There is a keycloak API, that collects the user login-logout entries in it. "http://localhost:8080/auth/admin/realms//events?dateFrom=2022-02-09&dateTo=2022-02-10&first=0&max=9999999&type=LOGIN&type=LOGIN_ERROR&type=LOGOUT&type=LOGOUT_ERROR" when ever user is refreshing the Angular App on browser window, each of refresh action is considered as a login entries and this API response keep on increasing with log. How to prevent this and get the log only for Login & Logout entires.
Here is the configuration set in app.init.ts
import { KeycloakService } from 'keycloak-angular';
import {keycloakConfigs } from '../../assets/config/serverdetails.json';
export function initializeKeycloak(keycloak: KeycloakService): () => Promise<boolean> {
return () =>
keycloak.init({
config: {
url: keycloakConfigs.Url,
realm: keycloakConfigs.Realm,
clientId: keycloakConfigs.ClientId,
},
initOptions: {
onLoad: 'login-required',
checkLoginIframe: true,
checkLoginIframeInterval: 25
},
loadUserProfileAtStartUp: true
});
}
keycloak
angular8
openid-connect
keycloak-angular
0 Answers
Your Answer