Return URL with Angular 6, angular-oauth2-oidc and IdentityServer 3

1.4k Views Asked by At

I have an angular 6 application, using JWT and IdentityServer 3 for authentication. Everything works as expected. However, I send an detail link from the application via email. If a user clicks the link, the browser opens with the URL, redirects to the identity server and uses the AD to login. After this, the application returns to the default application root view, loosing the clicked URL.

I have searched quite a bit, but I never found a full solution to my problem. I save the location.href to session storage on "ngOnInit" and redirect to this, after I receive the event "token_received" from angular-oauth2-oidc. However, this doesn't seem to work, as it saves the link with the token in the URL, not my initial call.

What is the solution to this problem?

2

There are 2 best solutions below

1
Noman Fareed On

As the application you have registered on AD, you must have configured a redirectURI for you application. So after successful authentication it will always redirects to that redirectURI you have configured for the application.

0
callee.args On

Use state parameter or store state against the nonce in localStorage. More details here:

https://auth0.com/docs/protocols/oauth2/redirect-users