-
-
Couldn't load subscription status.
- Fork 461
Open
Labels
Description
Expected Behavior
TOTP token validation should work consistently across all browsers after scanning the QR code and entering the 6-digit token from the authenticator app.
Current Behavior
- Safari/Firefox: Token validation always succeeds ✅
- Chrome/Edge: Token validation always fails with "Entered token is not valid" ❌
The TOTP comparison in forms.py never evaluates to True on non-Safari browsers:
if totp(key, self.step, t0, self.digits, self.drift + offset) == token:
# This is never True on Chrome/Firefox/EdgePossible Solution
Since it's browser-specific, it might be related to:
- How different browsers handle form data encoding
- Session/cookie handling differences
- other ... ?
Steps to Reproduce (for bugs)
- Setup django-two-factor-auth following the standard documentation
- Login and start 2FA setup process
- Scan QR code with any authenticator app
- Enter the 6-digit token
- Submit form
- Result: Works on Safari and Firefox, fails on Chrome and Edge
Context
I'm implementing 2FA for a Django application. Everything works perfectly on Safari but fails consistently on all other browsers. This is blocking deployment as users can't enable 2FA unless they use Safari/Firefox.
Your Environment
- Browser and version: Safari/Firefox (works), Chrome/Edge latest versions (fail)
- Python version: 3.12.11
- Django version: 4.0.5
- django-otp version: (included with django-two-factor-auth)
- django-two-factor-auth version: 1.16.0