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

Add error.code for the RPerror classes #250

Closed
1 task done
tabarra opened this issue Apr 22, 2020 · 3 comments
Closed
1 task done

Add error.code for the RPerror classes #250

tabarra opened this issue Apr 22, 2020 · 3 comments

Comments

@tabarra
Copy link
Contributor

tabarra commented Apr 22, 2020

Is your feature request related to a problem? Please describe.
I would like to know when an code exchange error could be solved by synchronizing the host clock (90% of the problems my users have), but checking the error for error.message.startsWith('JWT expired, now') is a bit too hacky.

Describe the solution you'd like
Add the property code for the RPerror class with a small, likely stable, string indicating the issue.
Examples: jwt_nbf_invalid, jwt_expired.
Alternatively, you could add the an CLOCK_TOLERANCE property to any error that is related to this variable.

Describe alternatives you've considered

  • Checking for the error message doesn't seems to stable;
  • Reading the error.jwt and re-checking those cases is redundant;
  • Adding some NTP client lib to make sure the clock is updated is too much of an overhead;
  • Telling my users to update their clocks on every Code Exchange error;

Additional context
My open source project is very very often deployed on windows servers right after deployment, with some atrocious clocks.

  • i have searched the issues tracker on github for similar requests and couldn't find anything related.
@panva
Copy link
Owner

panva commented Apr 22, 2020

@tabarra thanks for the suggestion.

Is it safe to say you want to be able to identify these four specific errors?

printf: ['too much time has elapsed since the last End-User authentication, max_age %i, auth_time: %i, now %i', maxAge, payload.auth_time, timestamp - this[CLOCK_TOLERANCE]],
printf: ['JWT issued too far in the past, now %i, iat %i', timestamp, payload.iat],
printf: ['JWT not active yet, now %i, nbf %i', timestamp + this[CLOCK_TOLERANCE], payload.nbf],
printf: ['JWT expired, now %i, exp %i', timestamp - this[CLOCK_TOLERANCE], payload.exp],

@tabarra
Copy link
Contributor Author

tabarra commented Apr 22, 2020

Would be awesome to have code for all errors, since I would also like to handle timeout errors more gracefully, but those are more "edge cases".
Having an error code (or some other identifier) for those 4 would certainly help me out a lot!

And as always, thanks for the responsiveness @panva!

@panva panva closed this as completed in fe3db5c Apr 28, 2020
@tabarra
Copy link
Contributor Author

tabarra commented May 4, 2020

Worked perfectly!
Once again, thanks for being so open to small tweaks!

@github-actions github-actions bot locked and limited conversation to collaborators Aug 3, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants