angular-auth-oidc-client: TypeError when implementing a `CanLoad` guard and `postLoginRoute` having no effect
Describe the bug
- TypeError when implementing a
CanLoadguard. 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:
git clone https://gitlab.com/hadrien-toma/issue && cd issue- Install modules:
cd antique-white/workspace && yarn install ; cd .. - Run Keycloak (it will create a realm
my-realm, a client with IDmy-client-idand a user withadmin/adminas username/password):scripts/antique-white/run/keycloak/index.bash - Run the Angular application:
scripts/antique-white/run/my-realm/my-client-id/index.bash
Expected behavior
- Without the dirty
try/catch/setTimeouttrick of theCanLoadguard, I get the following error:
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)
- Moreover I tried to use the
postLoginRoutein order to dynamically redirect the user to the page asked before the navigation when the guard run theauthorizecommand but it doesn’t seem to do something, maybe am I not using it correctly?
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)
We tried to describe it in the docs. You will have to: Use the
AutoLoginGuardfrom 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 callcheckAuth()in your app component.So you have to do:
canActivateandcanLoad, both should workcheckAuth()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.