You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
The Angular Router can get into a infinite loop in Firefox when Router.navigateByUrl is invoked and the token from the IdP contains an error.
I believe others are not seeing this issue in the masses because it requires the IdP redirection location to first land on an "confirmation page", this page then redirects the app to the proper application route, based on success or failure. When failure occurs the window.location contains a hash in the URL. Which causes the Angular router to invoke popstate immediately after the navigateByUrl routing has completed.
What is Occurring:
Angular Application bootstraps and tryLogin is invoked on app.component
Within this method an attempt is made to clear location.hash if configured and set location.hash = ''(code)
In Firefox only! location.hash = '' will actually add hash to the URL!
Error bubbles out from oauth2 lib and app.component calls Router.navigateByUrl
Routing successful
popstate occurs in Angular router redirecting the app back to app.component
tryLogin is again attempted by app.component; process repeats (GOTO step 2)
Expected behavior
No infinite routing loops 😄
Additional context
Firefox adds a hash to the URL if you attempt to clear it with an empty string. This can be fixed by first checking if location.hash contains a hash before trying to clear it with an empty string.
I believe fixing this would address other issues that have workarounds: #493 #408
This issue also describes the problems using location.hash and Angular Router #622
The text was updated successfully, but these errors were encountered:
cgatian
pushed a commit
to cgatian/angular-oauth2-oidc
that referenced
this issue
Nov 5, 2020
I was running into continuous redirection / race conditions in firefox and I found that setting the configuration to clearHashAfterLogin = false solved the problem. the hash removal was causing it to redirect back to login. /login#token -> /home -> /login
I also use an intermediary page (/login) to receive the token and then route accordingly. I use this strategy because I have auth guards.
@rinella thats also what I am doing (as a workaround). There's issues with Angular apps that use hashed based routing. I wish the PR would just be merged :)
Describe the bug
The Angular Router can get into a infinite loop in Firefox when
Router.navigateByUrl
is invoked and the token from the IdP contains an error.I believe others are not seeing this issue in the masses because it requires the IdP redirection location to first land on an "confirmation page", this page then redirects the app to the proper application route, based on success or failure. When failure occurs the
window.location
contains a hash in the URL. Which causes the Angular router to invokepopstate
immediately after thenavigateByUrl
routing has completed.What is Occurring:
tryLogin
is invoked onapp.component
handleLoginError
is invokedlocation.hash
if configured and setlocation.hash = ''
(code)location.hash = ''
will actually add hash to the URL!app.component
callsRouter.navigateByUrl
popstate
occurs in Angular router redirecting the app back toapp.component
tryLogin
is again attempted byapp.component
; process repeats (GOTO step 2)Expected behavior
No infinite routing loops 😄
Additional context
Firefox adds a hash to the URL if you attempt to clear it with an empty string. This can be fixed by first checking if
location.hash
contains a hash before trying to clear it with an empty string.I believe fixing this would address other issues that have workarounds:
#493
#408
This issue also describes the problems using
location.hash
and Angular Router#622
The text was updated successfully, but these errors were encountered: