• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

kobotoolbox / kpi / 43184244100
86%
master: 76%

Build:
Build:
LAST BUILD BRANCH: release/2.026.43
DEFAULT BRANCH: master
Ran 12 Nov 2026 08:40AM UTC
Jobs 10
Files 891
Run time 1min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

12 Nov 2026 08:35AM UTC coverage: 85.974% (+0.05%) from 85.927%
43184244100

push

github

web-flow
fix(mfa): accept legacy recovery codes in the new 2FA screens DEV-3251 (#7844)

### 📣 Summary
Recovery codes from the former 2FA system now work in the new login and
Security screens, as they do on the old pages.

### 📖 Description

**Problem**

KPI used to handle two-factor authentication (2FA) with a library called
"Trench", and later moved to django-allauth. Trench never kept recovery
codes as plain text: it stored a hash of each code, the same way
passwords are stored. When we moved to allauth, those hashes were copied
as they were into allauth's `mfa_authenticator` table, in the
`migrated_codes` field of each user's recovery codes.

allauth checks a recovery code by comparing what the user types with the
stored text. For these old codes the stored text is a hash, so a correct
code never matches. To keep them working, KPI added its own check, which
hashes what the user types and compares it with the stored hash.
allauth's login and "Confirm it's you" pages were set up to use KPI's
check, so old codes kept working there.

The new login and account screens use allauth's headless API instead,
and those endpoints don't go through KPI's check. So a valid old
recovery code is refused with "Incorrect code." For someone who has lost
their authenticator app, that code is the only way in.

**What this PR does**

This PR makes the new screens use KPI's check again, so that no user is
locked out because of the migration. To do that:

- **One shared check:** the code check now lives in one place,
`validate_mfa_code()`. KPI's own 2FA endpoints, allauth's pages and the
new headless endpoints all use it.
- **Headless 2FA endpoints:** the 2FA step of the login
(`auth/2fa/authenticate`) and the "Confirm it's you" step
(`auth/2fa/reauthenticate`) now use KPI's check, for both the `browser`
and `app` clients.
- **Recovery codes list:** for old codes, only hashes are stored, so the
recovery codes endpoint now shows how many old codes are left instead of
listing the ha... (continued)

10927 of 13742 branches covered (79.52%)

63 of 104 new or added lines in 7 files covered. (60.58%)

2 existing lines in 1 file now uncovered.

34178 of 39754 relevant lines covered (85.97%)

5.82 hits per line

Uncovered Changes

Lines Coverage ∆ File
22
37.29
-15.84% kobo/apps/accounts/mfa/utils.py
7
54.55
54.55% kobo/apps/accounts/mfa/forms.py
5
51.52
16.43% kobo/apps/accounts/mfa/serializers.py
4
63.91
1.84% kobo/apps/accounts/views.py
3
63.33
10.95% kpi/utils/urls.py

Coverage Regressions

Lines Coverage ∆ File
2
54.55
54.55% kobo/apps/accounts/mfa/forms.py
Jobs
ID Job ID Ran Files Coverage
1 43184244100.1 12 Nov 2026 08:40AM UTC 886
50.06
2 43184244100.2 12 Nov 2026 08:41AM UTC 888
51.42
3 43184244100.3 12 Nov 2026 08:42AM UTC 886
59.47
4 43184244100.4 12 Nov 2026 08:42AM UTC 886
54.45
5 43184244100.5 12 Nov 2026 08:43AM UTC 888
55.78
6 43184244100.6 12 Nov 2026 08:43AM UTC 886
57.45
7 43184244100.7 12 Nov 2026 08:43AM UTC 889
66.46
8 43184244100.8 12 Nov 2026 08:43AM UTC 888
60.64
9 43184244100.9 12 Nov 2026 08:44AM UTC 891
68.96
10 43184244100.10 12 Nov 2026 08:44AM UTC 888
59.04
Source Files on build 43184244100
  • Tree
  • List 891
  • Changed 8
  • Source Changed 0
  • Coverage Changed 8
Coverage ∆ File Lines Relevant Covered Missed Hits/Line Branch Hits Branch Misses
  • Back to Repo
  • 426e6b5b on github
  • Prev Build on main (#43176785451)
  • Next Build on main (#43196965022)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc