How to handle conditional init of keycloak? #313
Labels
enhancement
This issue/PR is an enhancement or new feature.
evaluate-in-next-version
Evaluate if the feature or change might be included in the next library release.
We have a requirement in our project to provide identity management based on user's choice while installing the app (Angular + Electron). To do so we have a public endpoint which upon request returns Auth Config with realm, client, url etc. And when the config is not provided we skip the keycloak init.
Problem is that there are multiple instances of Keycloak service within the application (guard, header, directive...) and they fail when Keycloak init was skipped.
Versions.
keycloak-angular: 8.0.1,
keycloak-js: 11.0.3,
angular: ~9.1.x
Repro steps.
We extended the APP_INITIALIZER with conditional handling of Promise chain like below and it works:
Now the problem is that checking for
!!this.keycloak
seems to be not working and the application is trying to obtain user profile or authentication confirm while keycloak service is not initialized/accessible. It's especially difficult with theAuthGuard
which extendsKeycloakAuthGuard
as we are not sure how to override it. This leads to following errors in our application.I'm aware that this is highly specific and quite rare issue and it most likely won't be handled on your side but at least some guidance would help as I am bit stuck and not sure how to continue.
Desired functionality.
???
The text was updated successfully, but these errors were encountered: