tiuub / KeeOtp2

KeeOtp2 is a plugin for KeePass. It provides a form to display one time passwords and is fully compatible with the built-in OTP function.
MIT License
126 stars 11 forks source link

Request: ability to adjust time manually or to base time on something else than just system time #10

Closed EvEvans closed 3 years ago

EvEvans commented 3 years ago

On my laptop (from work) I kept getting wrong TOTP keys, and when clicking Wrong? (button) -> Ping Google for current time (button) it shows my time is 87 seconds off with the time from Google. Sadly, I cannot change the system time manually, nor can I change the (company-based) time-server which is set by company policy. So on this laptop, it seems there is no way for me to get a correct TOTP key using this plugin.

To fix this, I can think of the possibility of pinging a server for the current time (in a similar way that button works), or by manually or (semi-)automatically setting a value which offsets the system time by a certain amount. Do you think a fix is possible for this situation?

tiuub commented 3 years ago

Hi, thank you for your feedback. This should be possible. I will try to implement this in the next 2 or 3 day and send you a pre-release. If the next "bigger" update comes up, I will fully implemented it.

I will notify you if I finished the pre-release.

EvEvans commented 3 years ago

Wow you are really fast in replying, many thanks!!

tiuub commented 3 years ago

Here is the pre-release. Just try it. It would be great if you give some feedback, if you run into an issue.

KeeOtp2 - 1.5.0.1(pre).zip

EvEvans commented 3 years ago

Thanks for the update! Sorry, I couldn't try it earlier, but I just loaded this version and KeePass (newest version) gives the following error: "The following plugin is incompatible with the current KeePass version ..."

I also saw there is now a version 1.5.2 of KeeOtp2, not sure if this includes the exact fix of 1.5.0.1(pre), but it seems so. Some feedback: When I now click "Ping NTP server for current time", it says my timing is 26,5 seconds before (maybe my companies time server updated), and that may work but I should check my time settings. When I then go in plugin settings of KeeOtp and click "use custom NTP server" (default time-a.nist.gov), it then says I'm only 0,5 seconds off, so that fixed it! Many thanks!!

I think the custom NTP server is more elegant than manually offsetting the time, also because the offset of my companies time server seems to vary over time. But great that you offer both solutions.

Thanks again for your quick work and fix, have a nice day.

tiuub commented 3 years ago

Yes, version 1.5.2 includes everything which was fixed in 1.5.0.1(pre). The error you described was a known bug in 1.5.0, which happened mainly on 32-bit systems, which I fixed wit version 1.5.1.

So with version 1.5.2 everything should work nicely for you.

EvEvans commented 3 years ago

Not sure if a new issue is needed for this, since it directly relates to the above fix. When I startup my laptop Keepass gives this message:

"Error Polling the NTP Server failed. Please confirm your entered address! Error message: No such host is known"

This is probably due to Keepass starting up before wifi is connected.

A delay or other way of giving out this message would be great. Maybe it is also possible to only perform this check whenever a TOTP code is requested by "Copy TOTP" or "Timed One Time Password", and then only once in a while?

tiuub commented 3 years ago

The plugin should be quite now on the startup of your pc. I have implemented a "retry" function. If there is no connection to the internet while polling the ntp server, the plugin will now wait 20 seconds and tries again after waiting. It will retry five times until the last known time will be used.

In near future, I had planned to give you the option to make it configurable how often and when it should retry. But for now this should work for you.