mauriciovigolo / keycloak-angular

Easy Keycloak setup for Angular applications.
MIT License
725 stars 278 forks source link

If Keycloak Auth Domain is down, then Angular 16 keycloak will receive white-page and fail compilation at AppModule level #565

Open fogarty-climbs opened 4 months ago

fogarty-climbs commented 4 months ago

Bug Report or Feature Request (mark with an x)

GIVEN an incorrect BAD_DOMAIN in the Keycloak configuration and Keycloak registered in the App.Module WHEN the App.Module attempts to compile and initialize Keycloak with a domain that is down THEN I will encounter a compilation error and will see no useful information and I cannot proceed even if I want anonymous access.

- [x ] bug report -> please search for issues before submitting

Versions.

"@angular/core": "^16.2.12", "keycloak-angular": "^14.0.0", "keycloak-js": "^18.0.0",

Repro steps.

  1. Install Angular 16 and Keycloak angular libraries.
  2. Configure kc.init.ts with a BAD_DOMAIN keycloakConfig: { url: 'BAD_DOMAIN', realm: 'realm-example', clientId: 'example-client-id', }; return keycloak.init({ config: keycloakConfig, initOptions: { onLoad: 'check-sso', silentCheckSsoFallback: false, silentCheckSsoRedirectUri: document.baseURI + 'assets/silent-check-sso.html', checkLoginIframe: false, enableLogging: true, checkLoginIframeInterval: 10_000, }, bearerExcludedUrls: [ 'https://api-dev.publicrecords.usco.lctl.gov/search_service', 'https://api-test.publicrecords.usco.lctl.gov/search_service', ], enableBearerInterceptor: true, });

The log given by the failure.

You will receive a white-page and Angular compilation stops at App.Module level. No useful information will be rendered or compiled.

Desired functionality.

A graceful failure where the application will render. This is a big blocker for websites that utilize Keycloak for logins but fails if the application needs anonymous access as well. If the Keycloak /auth/ domain is ever down, you will receive the whitepage. An expectation would be if the Keycloak /auth/ domain is down for the application, we would want to disable login features.