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

TOTP Code Repeatedly Fails #289

Closed
u-ashish opened this issue Apr 8, 2020 · 1 comment
Closed

TOTP Code Repeatedly Fails #289

u-ashish opened this issue Apr 8, 2020 · 1 comment

Comments

@u-ashish
Copy link

u-ashish commented Apr 8, 2020

Hi there,

Was attempting to set up authboss in my golang API and did a straight-forward TOTP implementation.

I was able:

  • to login
  • hit POST /auth/2fa/totp/setup
  • get the code GET /auth/2fa/totp/confirm which returns
{
    "modules": {
        "auth": true,
        "lock": true
    },
    "status": "success",
    "totp_secret": "<SECRET_IN_SESSION>"
}
  • get the QR code (GET /auth/2fa/totp/qr)
  • use Authenticator or Authy and register via QR (Also tried manually). On my iPhone.
  • make a post to /auth/2fa/totp/confirm with this request body:
{
	"code": "<CODE_FROM_APP>"
}
  • It fails every time (no matter which app).

I'm assuming it has to do with the logic used to generate the code (duration, secret, etc.) but not sure what the recommended way to debug/solve this is.

I confirmed from my debugger that the TOTP secret it uses to decode is the same that I registered in the authenticator app. Looking at your source code it seems the default behavior you used is supposed to be compatible, so I'm trying to understand what else might cause this to deviate.

For fun I ran your totp.GenerateCode(...) method and passed that in and it worked, so there's something about how it generates/validates codes via the default options that might be off from the three different auth apps on my iPhone:

  • Google Authenticator
  • Authy
  • Authenticator

Or maybe I'm missing something...

@u-ashish
Copy link
Author

u-ashish commented Apr 8, 2020

Hmm, I do see that you use the pquerna/otp package (which if I did this manually, I'd have used as well), so I'm even more confused as to why the code from my app after registering via QR is not the same as what the algo generates.

(I made sure I was using the right code 😄 )

This... appears to have resolved itself so closing...

@u-ashish u-ashish closed this as completed Apr 9, 2020
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

1 participant