Skip to content
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

Redirect users to login page on NONCE mismatch #142

Closed
KarolisL opened this issue Nov 7, 2019 · 9 comments
Closed

Redirect users to login page on NONCE mismatch #142

KarolisL opened this issue Nov 7, 2019 · 9 comments

Comments

@KarolisL
Copy link
Collaborator

KarolisL commented Nov 7, 2019

Sometimes users get NONCE mismatch. I've seen some similar log messages:

SignInFailedNonce received=9a7ea569fe96459688ad03d51cd63678 sent=null

My hypothesis is that user mistakenly either:

  • manually old visits auth0 login page ( `https://<auth0_domain>.eu.auth0.com/login?state=&protocol=oauth2&audience=&scope=profile%20openid%20email&response_type=code&redirect_uri=https%3A%2F%2F<real_website_domain>%2Foauth2%2Fsignin
  • manually old visits /oauth2/signin ( https://<real_website_domain>/oauth2/signin?code=hgfbmMwAu5iBV8ZL&state=<snip>

The error page on <real_website_domain>/oauth2/signin (400 BAD REQUEST) confuses users and refresh doesn't mitigate the error since NONCE is still invalid.

Would it make sense to redirect users back to auth0 just like they were coming to the page for the first time (in order to set proper NONCE)?

@KarolisL
Copy link
Collaborator Author

KarolisL commented Nov 7, 2019

AUTH_NONCE Cookie is set with Max-Age of 60, so if we go to a <real_website>, get reidirected to login screen, wait for 61 seconds and log in, we get the ApplicationException.

Could we make maxAge configurable? Or would it be a security risk? v1 had this cookie set to -1

@dniel
Copy link
Owner

dniel commented Nov 7, 2019

@KarolisL yeah, I agree, 60 seconds is a little bit to aggressive. I set it like that because the token exchange code Auth0 send is valid for about 60 seconds probably and to tighten security. But as you point out its possible that the user let the login page waiting for 10 min before actually clicking sign in.

I'll add a configuration to specify maxAge in config, and set a more sensible default, maybe 5 or 10 minutes valid cookie time.

@dniel
Copy link
Owner

dniel commented Nov 7, 2019

@KarolisL like you say when the user get a nonce error on the screen, I have seen the errors mostly when using back button and/or reload page. I'll try to investigate about setting a default login page in Auth0. I think maybe they have something like that.

@KarolisL
Copy link
Collaborator Author

KarolisL commented Nov 11, 2019

@dniel in my case, configuring the maxAge would be enough, for now, I could make a PR for this feature.
Regarding the redirect, the UX isn't that great with nonce errors, because user tends to refresh the page if s/he gets an error, but it is futile to refresh because nonce won't match no matter how many times you would refresh. Another solution would be to add "try again" button. Maybe this relates to #63?

@dniel
Copy link
Owner

dniel commented Nov 11, 2019

@KarolisL Thanx for the PR! Could you update your branch to exclude sonarcloud testing in PR-builds to make the PR build succeed? https://travis-ci.community/t/pull-request-builds-fail-with-sonar/3473

@dniel
Copy link
Owner

dniel commented Nov 11, 2019

@KarolisL I have created a new project https://github.com/dniel/forwardauth-ui for implementing a react UI application. #63 will probably be solved there.

@KarolisL
Copy link
Collaborator Author

@dniel I have updated the PR to disable sonar on PRs.

@dniel
Copy link
Owner

dniel commented Nov 12, 2019

@KarolisL thanx for the help, please close this issue when you have verified that the new build is working.

@KarolisL
Copy link
Collaborator Author

I've just checked, the new build worked!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants