Page MenuHomePhabricator

Separate recovery codes into a separate 2FA module
Closed, ResolvedPublic

Description

We should separate the Recovery codes from OATHAuth into a separate MFA authentication module and detach if from the TOTP method as WebAuthn does not have a (self) recovery method of its own.

See also: T218214#5474912

Related Objects

Event Timeline

There are a very large number of changes, so older changes are hidden. Show Older Changes
Reedy renamed this task from Separate recovery codes into a separate MFA method to Separate scratch/recovery codes into a separate MFA method.Dec 6 2023, 12:39 PM
Reedy renamed this task from Separate scratch/recovery codes into a separate MFA method to Separate recovery codes into a separate MFA method.Jan 1 2024, 8:54 PM
Reedy updated the task description. (Show Details)
Tgr subscribed.

Let's do it in the other way, this has so many child/parent tasks, seems like a chore to move them.

Tgr renamed this task from Separate recovery codes into a separate MFA method to Separate recovery codes into a separate 2FA module.Jul 31 2025, 4:49 PM
Tgr added subscribers: sbassett, Mstyles, TAdeleye_WMF.

So this needs:

  • a new 2FA module in OATHAuth
  • making the backup code part of the TOTP UI optional (both for setup and for verification)
  • some sort of workflow for ensuring that generating backup codes is still integrated with the TOTP setup flow (and presumably it would also integrate them with the WebAuthn setup flow)
  • a feature flag for switching from generating as part of TOTP setup to generating via this new workflow
  • a migration script that copies codes from existing TOTP records into separate DB rows, to be run once the feature flag was switched

Do we want to fix the recovery code part of T145915: OATHAuth OTP shouldn't be stored in cleartext in the DB as part of this?

Yes, I think that's a good idea, that way the data only needs to be migrated once.

Change #1182964 had a related patch set uploaded (by SBassett; author: SBassett):

[mediawiki/extensions/OATHAuth@master] Separate recovery codes into a separate 2FA module

https://gerrit.wikimedia.org/r/1182964

Test wiki created on Patch demo by SBassett (WMF) using patch(es) linked to this task:
https://b72e3e9d3e.catalyst.wmcloud.org/w/

Change #1187874 had a related patch set uploaded (by SBassett; author: SBassett):

[mediawiki/extensions/WebAuthn@master] Define isSpecial() for WebAuthn module

https://gerrit.wikimedia.org/r/1187874

Test wiki on Patch demo by SBassett (WMF) using patch(es) linked to this task was deleted:

https://b72e3e9d3e.catalyst.wmcloud.org/w/

Test wiki created on Patch demo by SBassett (WMF) using patch(es) linked to this task:
https://74054e2b29.catalyst.wmcloud.org/w/

Test wiki on Patch demo by SBassett (WMF) using patch(es) linked to this task was deleted:

https://74054e2b29.catalyst.wmcloud.org/w/

Change #1187874 merged by jenkins-bot:

[mediawiki/extensions/WebAuthn@master] Define isSpecial() for WebAuthn module

https://gerrit.wikimedia.org/r/1187874

Test wiki created on Patch demo by SBassett (WMF) using patch(es) linked to this task:
https://a0f99dc0d8.catalyst.wmcloud.org/w/

Test wiki on Patch demo by SBassett (WMF) using patch(es) linked to this task was deleted:

https://a0f99dc0d8.catalyst.wmcloud.org/w/

Change #1191180 had a related patch set uploaded (by SBassett; author: SBassett):

[mediawiki/extensions/WebAuthn@master] Add Recovery Codes support to WebAuthn add key page

https://gerrit.wikimedia.org/r/1191180

Change #1191390 had a related patch set uploaded (by Reedy; author: Reedy):

[mediawiki/extensions/OATHAuth@master] Add maintenance script to migrate recovery tokens to their own device

https://gerrit.wikimedia.org/r/1191390

Change #1182964 merged by jenkins-bot:

[mediawiki/extensions/OATHAuth@master] Separate recovery codes into a separate 2FA module

https://gerrit.wikimedia.org/r/1182964

Change #1191180 merged by jenkins-bot:

[mediawiki/extensions/WebAuthn@master] Add Recovery Codes support to WebAuthn add key page

https://gerrit.wikimedia.org/r/1191180

sbassett removed a project: Patch-For-Review.
sbassett moved this task from In Progress to Done on the user-sbassett board.

Just noting here that @Tgr made some additional review comments on change https://gerrit.wikimedia.org/r/1182964 after the merge

Just noting here that @Tgr made some additional review comments on change https://gerrit.wikimedia.org/r/1182964 after the merge

Thanks. There are going to be several cleanup-related tasks for this work that we hope to resolve within the near future, largely due to the clunky, dual-state of handling older TOTP-attached scratch tokens and the newer recovery codes. Eventually, we plan to migrate all Wikimedia project users with existing TOTP/scratch tokens to TOTP and separate recovery codes. Anyhow, I'll file a separate bug now to track the handful of recommendations @Tgr made on the change set.

Change #1191390 merged by jenkins-bot:

[mediawiki/extensions/OATHAuth@master] Add maintenance script to migrate recovery tokens to their own device

https://gerrit.wikimedia.org/r/1191390

Change #1198162 had a related patch set uploaded (by Reedy; author: Reedy):

[mediawiki/extensions/OATHAuth@wmf/1.45.0-wmf.24] Add maintenance script to migrate recovery tokens to their own device

https://gerrit.wikimedia.org/r/1198162

Change #1198163 had a related patch set uploaded (by Reedy; author: Reedy):

[mediawiki/extensions/OATHAuth@wmf/1.45.0-wmf.23] Add maintenance script to migrate recovery tokens to their own device

https://gerrit.wikimedia.org/r/1198163

Change #1198162 merged by jenkins-bot:

[mediawiki/extensions/OATHAuth@wmf/1.45.0-wmf.24] Add maintenance script to migrate recovery tokens to their own device

https://gerrit.wikimedia.org/r/1198162

Change #1198163 merged by jenkins-bot:

[mediawiki/extensions/OATHAuth@wmf/1.45.0-wmf.23] Add maintenance script to migrate recovery tokens to their own device

https://gerrit.wikimedia.org/r/1198163