-
Notifications
You must be signed in to change notification settings - Fork 694
OAuthErrorEvent: {"type":"invalid_nonce_in_state","reason":null,"params":null} #1217
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Huhmm, interesting situation. Thx for sharing a clear repro! It's a bit of an odd set of steps though, or at least step 4 is? I can imagine this library cannot handle it if localStorage is cleared halfway through the process... But then again, perhaps step 4 is simulating some real world situation we don't know about yet? Looking at the code of the service, it does indeed not like it if localStorage gets cleared, because you're bypassing the library's internal storage mechanisms, and I think you might be missing clearing out other parts, like the nonce, which is saved in angular-oauth2-oidc/projects/lib/src/oauth-service.ts Lines 2497 to 2503 in d95d7da
Some things you can try to test this:
Hope these steps help you find a solution! Let us know if there's a real world situation where step 4 would happen for actual users, because if it is I guess this issue would instead be a missing feature or bug in the library. |
I was able to get it tow work by using I pushed the working version to the GH repo as a reference if others are struggling with this, too. The original code is still available in the |
Good to hear! And thanks for sharing 👍 |
Describe the bug
After successful login using implicit flow and retrieval of Access/ID token the login fails if the local storage is cleared. Login is only possible again after the token expired.
Stackblitz example
I uploaded a minimal application which reproduces the bug: https://github.com/tiefenauer/angular-oauth2-oidc-bug
To Reproduce
Steps to reproduce the behavior:
auth-config.ts
with real values (issuer, clientId and userInfoEndpoint)ng serve
4.open http://localhost:4200/ --> you are redirected to your IDPs login page (OK)
I noticed a similar issue #728 suggesting there's a race condition.
Expected behavior
When calling
oauthService.loadDiscoveryDocumentAndLogin()
without a nonce in the local storage the login process should start anew.Additional context
When disabling nonce check it works, but that can't be the solution since it leaves the application vulnerable to replay attacks.
see https://github.com/tiefenauer/angular-oauth2-oidc-bug/blob/main/src/app/auth/auth.service.ts#L27-L30
The text was updated successfully, but these errors were encountered: