peburrows / goth

Elixir package for Oauth authentication via Google Cloud APIs
http://hexdocs.pm/goth
MIT License
284 stars 108 forks source link

Fix "Too many failed attempts" with `:os.system_time` #122

Closed aleDsz closed 2 years ago

aleDsz commented 2 years ago

Fixes #113.

This should stop making wrong calls when a dev computer is sleeping/off.

System.system_time/1:

Returns the current system time in the given time unit.

It is the VM view of the os_time/0. They may not match in case > of time warps although the VM works towards aligning them. This time is not monotonic.

aleDsz commented 2 years ago

I'll be testing this change with sleeping/shutting down my computer to check if the issue still happening

aleDsz commented 2 years ago

I'll be testing this change with sleeping/shutting down my computer to check if the issue still happening

Changing the system current time (or timezone) makes the system gets the wrong :os.system_time/1 and it sends wrong iat and exp claims to Google OAuth2 API and crashes the Goth.Server.

Maybe if we try to get the system timezone and caches it, maybe can solve this issue. I'll try more possibilities until this PR be ready for review.


EDIT: Actually, maybe this can't be solve, since it uses the OS current time, if the current OS has wrong Date and Time settings, Erlang can't handle that.