angular-auth-oidc-client: TypeError when implementing a `CanLoad` guard and `postLoginRoute` having no effect

Describe the bug

  • TypeError when implementing a CanLoad guard.
  • authorize({customParams: {postLoginRoute}}) seems to do nothing

To Reproduce

In order to reproduce the behavior, I made a minimal example where the SSO is a docker-containerized Keycloak:

  1. git clone https://gitlab.com/hadrien-toma/issue && cd issue
  2. Install modules: cd antique-white/workspace && yarn install ; cd ..
  3. Run Keycloak (it will create a realm my-realm, a client with ID my-client-id and a user with admin/admin as username/password): scripts/antique-white/run/keycloak/index.bash
  4. Run the Angular application: scripts/antique-white/run/my-realm/my-client-id/index.bash

Expected behavior

ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'usePushedAuthorisationRequests' of null
TypeError: Cannot read property 'usePushedAuthorisationRequests' of null
    at LoginService.login (angular-auth-oidc-client.js:3876)
    at OidcSecurityService.authorize (angular-auth-oidc-client.js:4083)
    at MapSubscriber.project (app.module.ts:75)
    at MapSubscriber._next (map.js:29)
    at MapSubscriber.next (Subscriber.js:49)
    at CombineLatestSubscriber.notifyNext (combineLatest.js:73)
    at InnerSubscriber._next (InnerSubscriber.js:11)
    at InnerSubscriber.next (Subscriber.js:49)
    at BehaviorSubject._subscribe (BehaviorSubject.js:14)
    at BehaviorSubject._trySubscribe (Observable.js:42)
    at resolvePromise (zone-evergreen.js:798)
    at resolvePromise (zone-evergreen.js:750)
    at zone-evergreen.js:860
    at ZoneDelegate.invokeTask (zone-evergreen.js:399)
    at Object.onInvokeTask (core.js:28500)
    at ZoneDelegate.invokeTask (zone-evergreen.js:398)
    at Zone.runTask (zone-evergreen.js:167)
    at drainMicroTaskQueue (zone-evergreen.js:569)
    at ZoneTask.invokeTask [as invoke] (zone-evergreen.js:484)
    at invokeTask (zone-evergreen.js:1621)

Desktop:

  • Ubuntu 18.04
  • Chrome Version 88.0.4324.182 (Official Build) (64-bit)
  • "angular-auth-oidc-client": "^11.6.2",

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 22 (1 by maintainers)

Most upvoted comments

@FabianGosebrink following your fix, can you summarize what have I to implement on my side to make the MCVE working? I suppose this changed the last paragraph you described, isn’t it? 😣

We tried to describe it in the docs. You will have to: Use the AutoLoginGuard from the lib and protect the routes you want to protect. AUto Login will be executed on this routes and you will be automatically redirected TO this route once your have been redirected to your app again after logging in. You have to call checkAuth() in your app component.

So you have to do:

  1. Use the Guard on your Routes, canActivate and canLoad, both should work
  2. Use the checkAuth() call in your app component.

See here

@FabianGosebrink @hadrien-toma Thanks for this. The fix will be released in version 11.6.4

On it 😉 We’ll keep you posted here. Thanks.