onAuthorizationResultComplete doesn't return AuthorizationResult.authorized
See original GitHub issueI am trying to implement some code that runs after the AuthorizationResult is complete and authorized. In my own code (based on your dotnet-angular-azure-ad-oidc
sample), I consistently get AuthorizationResult.unauthorized
returned when the user is unauthorized. However, I cannot get it to returnAuthorizationResult.authorized
ever. To be clear, the authorization is successful, as I am able to see the token, and use the getIsAuthorized to change the nav bar.
In the constructor, I have:
this.oidcSecurityService.onAuthorizationResult.subscribe(
(authorizationResult: AuthorizationResult) => {
this.onAuthorizationResultComplete(authorizationResult);
});
which calls
private onAuthorizationResultComplete(authorizationResult: AuthorizationResult) {
console.log('AppComponent:onAuthorizationResultComplete');
const path = this.read('redirect');
if (authorizationResult === AuthorizationResult.authorized) {
this.router.navigate([path]);
} else {
this.router.navigate(['/Unauthorized']);
}
}
But as I said above, this only ever gets AuthorizationResult.unauthorized
passed into it. My hope is to add my own post-successful login code into the AuthorizationResult.authorized
code block above.
I have noticed that whether I run your sample code (pointing to our Azure AD), or my own code, that I get a TypeError: Cannot read property 'toLowerCase' of undefined
, which may or may not be related.
stack:"TypeError: Cannot read property 'toLowerCase' of undefined\n at HttpXsrfInterceptor.push../node_modules/@angular/common/fesm5/http.js.HttpXsrfInterceptor.intercept (http://localhost:4200/vendor.js:8032:29)\n at HttpInterceptorHandler.push../node_modules/@angular/common/fesm5/http.js.HttpInterceptorHandler.handle (http://localhost:4200/vendor.js:7412:33)\n at HttpInterceptingHandler.push../node_modules/@angular/common/fesm5/http.js.HttpInterceptingHandler.handle (http://localhost:4200/vendor.js:8085:27)\n at MergeMapSubscriber.project (http://localhost:4200/vendor.js:7163:184)\n at MergeMapSubscriber.push../node_modules/rxjs/_esm5/internal/operators/mergeMap.js.MergeMapSubscriber._tryNext (http://localhost:4200/vendor.js:79776:27)\n at MergeMapSubscriber.push../node_modules/rxjs/_esm5/internal/operators/mergeMap.js.MergeMapSubscriber._next (http://localhost:4200/vendor.js:79766:18)\n at MergeMapSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.next (http://localhost:420...
Finally, I do have the configuration set to call that event handler:
openIDImplicitFlowConfiguration.trigger_authorization_result_event = true;
This is with Angular 6.0.5 (sample code) and 5.2.9 (my code) on Node 8.11.1.
Any suggestions or ideas?
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (2 by maintainers)
PR 246 submitted
I figured it out!
Azure AD, which we are authenticating against, has not implemented the UserInfo end point. The default setting for
auto_userinfo
here in AuthConfiguration is “true”. This causes execution to go down the path:That subscribe doesn’t have a catch/catchError associated with it, so it just never executes. Hence, no
AuthorizationResult.authorized
is ever emitted, and theonAuthorizationResultComplete
is never called.Setting
openIDImplicitFlowConfiguration.auto_userinfo = false;
in app.module.ts made everything work properly.I’ll submit a pull request for adding the
catch
for your review shortly.