Open khan990 opened 3 years ago
I believe this may be a duplicate of https://github.com/mauriciovigolo/keycloak-angular/issues/289 but I agree that this is a serious issue that could stand to get some immediate attention.
At the very least, remove the automatic extension of CanActivate
To anybody looking through this thread, I had a similar issue with Keycloak causing infinite redirects after following the basic tutorial in the README. I tried numerous solutions found online including:
onLoad
from check-sso
to login-required
.checkLoginIframe
to false
.keycloak.login
function call out of the guard.loadUserProfileAtStartUp
to the keycloak init.Ultimately none of these solved the issue.
In the end I discovered (when moving the login call out of the guard) that the this.authenticated
check in the guard would always return false, even after successful logins. This implied to me there was an issue with the init rather than the guard. For me the solution then became adding an await
to the keycloak.init
. i.e. replacing:
function initializeKeycloak(keycloak: KeycloakService) {
return () =>
keycloak.init({
config: {
...
},
initOptions: {
...
}
});
}
with
function initializeKeycloak(keycloak: KeycloakService) {
return async () => {
await keycloak.init({
config: {
...
},
initOptions: {
...
},
});
};
}
Bug Report or Feature Request (mark with an
x
)Versions.
keycloak-angular@8.2.0 keycloak-js@14.0.0
Repro steps.
We have the following microfrontend architecture:![image](https://user-images.githubusercontent.com/2551269/124254951-ea8a3400-db29-11eb-8ac6-b2f99227b80c.png)
Keycloak on
host
gets initialised and authenticated. While in the angular elements it does not initialises and triggers a reload. We are using the following configuration in all our 3 instances (similar to described inkeycloak-angular
docs):The log given by the failure.
Nothing helpful. Logs are generated only by
host
and not byelements
:Desired functionality.
I would expect that angular elements initialise their instance seamlessly. Or may be I am missing something. Any hint would be appreciated.