sec51 / twofactor

Golang two factor authentication library
ISC License
217 stars 66 forks source link

After some time twofactor.TOTPFromBytes is not working #7

Open khawerrind opened 7 years ago

khawerrind commented 7 years ago

I am using your library. Everything works fine but all of sudden after few days. I am getting this error,

Could not verify the message. Message has been tempered with!

It does work fine for few days but don't know what happens and after few days twofactor.TOTPFromBytes is giving me the error. Can you please help me in identify the issue or how to resolve it?

Thank You!

silenteh commented 6 years ago

@khawerrind Sorry for the delay, but I completely missed this issue. I suspect the problem is related to the keys needed to decrypt the serialised TOTP structure. Is it possible that the keys are deleted ? You could check the creation and modification time of the files created inside the keys folder and see if they differ when the problem appears.

impronunciable commented 6 years ago

I'm seeing the same behavior. @khawerrind Did you fix it on your end?

silenteh commented 6 years ago

An update about this. I have found the issue and it's present in the library. I am working on a fix.

impronunciable commented 6 years ago

@silenteh that's great. Let me know if I can help you. Do you know when you'll be able to work on this?

thanks so much for the quick reply!

khawerrind commented 6 years ago

For me the keys were the issue. Since i was using docker container, i was not adding keys to the docker container. And whenever i restarted docker container new keys were being generated because of the missing old keys. So i just added keys to the docker image and everything works perfectly and never had that issue again.

impronunciable commented 6 years ago

Thanks @khawerrind I noticed I'm starting the build from different paths and the lib is looking for a path relative to the cwd

KashifJunaido2soft commented 6 years ago

@khawerrind, could you please share your code. actually i have a same kind of project so any help regarding to that would be really nice and time saving for me. Thanks