manfredsteyer / angular-oauth2-oidc

Support for OAuth 2 and OpenId Connect (OIDC) in Angular.
MIT License
1.86k stars 681 forks source link

Code flow breaks due to redirect #1414

Open Mangar2 opened 3 weeks ago

Mangar2 commented 3 weeks ago

Hi,

not really a bug, more a possibility to make your code more robust. Still found some internet q&a reporting the same poblem without solution.

Steps 1-4 of "code" flow worked fine until authority sent the code. "loadDiscoveryDocumentAndTryLogin" was not able to extract the code due to a redirect that happend by async processes in parallel to the loadDiscoveryAndTryLogin process.

(authGuards on all pages made the router redirecting and logically window.location.search was empty when loadDiscoveryDocumentAndTryLogin accessed it).

My suggestion: save the window.location.search content as soon as possible in loadDiscoveryAndTryLogin to prevent other async-task to clear it. It is hard to debug, if it happens.