Page MenuHomePhabricator

New database table for tracking WebAuthn userHandle values (oathauth_user_handles)
Closed, ResolvedPublic

Description

To support passwordless login with passkeys (T321708), the OATHAuth extension needs to be able to identify which user has a given userHandle value. The userHandle is a 64-byte binary string that is randomly chosen for each user. To support this lookup, we propose adding a simple 1-to-1 mapping table between user IDs and userHandle values.

Like the other oathauth_* tables, there would be one global instance of the oathauth_user_handles table in the centralauth database for all SUL wikis together, and a local instance in each database for non-SUL wikis.

Gerrit patch: https://gerrit.wikimedia.org/r/c/mediawiki/extensions/OATHAuth/+/1236403
Proposed schema: https://gerrit.wikimedia.org/r/c/mediawiki/extensions/OATHAuth/+/1236403/2/sql/tables.json

Checklist from https://wikitech.wikimedia.org/wiki/Creating_new_tables:

  • Should this table be replicated to wiki replicas (does it not contain private data)?
    • No, it should not be replicated, nor should the other oathauth_* tables. They contain data related to user authentication.
  • Will you be doing cross-joins with the wiki metadata?
    • No. We're currently not planning to join this table on anything. In the future I suppose we might want to join it against other oathauth_* tables, but probably not against anything else.
  • Size of the table (number of rows expected).
    • The size of this table will always equal the result of the query select count(distinct oad_user) from oathauth_devices join oathauth_types on oad_type=oat_id where oat_name='webauthn';. If we ran the population script in production today, the table in the centralauth DB would have 1,425 rows. This table will always be smaller than the oathauth_devices table.
  • Expected growth per year (number of rows).
    • We've had relatively high growth recently because we rolled out new WebAuthn-related features, leading to 1100 new users in 2 months. In the long run, growth will probably be less, probably about 5k rows per year.
  • Expected amount of queries, both writes and reads (per minute, per hour...per day, any of those are ok).
    • Writes only happen when a user adds their first WebAuthn-based 2FA key, or deletes their last one. I estimate this happens ~20 times per day.
    • Reads happen when a user who has 2FA tries to log in, or opens the 2FA management UI. I don't have numbers handy on how often this happens, but probably not a huge amount. This table will get the same amount of read traffic as the existing oathauth_devices table (they're usually read together).
  • Examples of queries that will be using the table.
    • SELECT oah_handle FROM oathauth_user_handles WHERE oah_user=N
    • SELECT oah_user FROM oathauth_user_handles WHERE oah_handle='X'
    • Simple inserts of one row at a time
    • DELETE FROM oathauth_user_handles WHERE oah_user=N
  • The release plan for the feature (are there specific wikis you'd like to test first etc).
    • Deploy the code from the attached patch (disabled behind a feature flag)
    • Enable the feature flag
    • Run the maintenance script to populate the table
    • Due to the global nature of authentication, it doesn't make sense to roll this out on a subset of wikis, we'd just deploy it everywhere at once

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

Change #1236403 had a related patch set uploaded (by Catrope; author: Catrope):

[mediawiki/extensions/OATHAuth@master] Add a database table to track WebAuthn userHandle values

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

Catrope updated the task description. (Show Details)

Note: as currently designed the oah_handle field is binary and contains binary values. However, we could store a base64-encoded value instead, if that is preferred.

Two notes:

  • Maybe add unsigned to give yourself more breathing room.
  • If you have the user as unique key, why not making it PK directly and avoid having an extra auto_increment id? See T411433#11584647 onwards

Two notes:

  • Maybe add unsigned to give yourself more breathing room.
  • If you have the user as unique key, why not making it PK directly and avoid having an extra auto_increment id? See T411433#11584647 onwards

Done. I was a bit confused about this, because I've been seeing a lot of new tables with auto_increment IDs even though there is a unique field. But this comment explains that perfectly:

As a rule of thumb: if the unique field is an integer, it's okay to use it as PK‌ (e.g. in redirect table, the page_id is PK) but if it's string, it's better to have a dedicate auto_increment PK.

@JAllemandou can you take a look if DE is impacted?

New table in the centralauth DB, no cloudDB replication and no need to sqoop into the cluster for now, DE is not impacted.

If it's waiting on DBA signoff, to make it clear that it looks good on our side. Just make sure: 1- to catalog it in table catalog 2- avoid creating it on all wikis (I think it'll be only non sul wikis + one central wiki).

Change #1236403 merged by jenkins-bot:

[mediawiki/extensions/OATHAuth@master] Add a database table to track WebAuthn userHandle values

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

DB table has been created on private.dblist, fishbowl.dblist and in centralauth.

Maintenance script presumably needs running?

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

[mediawiki/extensions/OATHAuth@master] Drop $wgOATHUserHandlesTable

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

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

[operations/mediawiki-config@master] CommonSettings: Temporarily set $wgOATHUserHandlesTable = true

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

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

[operations/mediawiki-config@master] Revert "CommonSettings: Temporarily set $wgOATHUserHandlesTable = true"

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

Change #1239025 merged by jenkins-bot:

[operations/mediawiki-config@master] CommonSettings: Temporarily set $wgOATHUserHandlesTable = true

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

Mentioned in SAL (#wikimedia-operations) [2026-02-12T11:05:23Z] <reedy@deploy2002> Started scap sync-world: Backport for [[gerrit:1238291|Allow a selection of third-level wmcloud/toolforge domains for UrlShortener (T413211)]], [[gerrit:1239025|CommonSettings: Temporarily set $wgOATHUserHandlesTable = true (T416544)]]

Mentioned in SAL (#wikimedia-operations) [2026-02-12T11:07:31Z] <reedy@deploy2002> filippo, reedy: Backport for [[gerrit:1238291|Allow a selection of third-level wmcloud/toolforge domains for UrlShortener (T413211)]], [[gerrit:1239025|CommonSettings: Temporarily set $wgOATHUserHandlesTable = true (T416544)]] synced to the testservers (see https://wikitech.wikimedia.org/wiki/Mwdebug). Changes can now be verified there.

Mentioned in SAL (#wikimedia-operations) [2026-02-12T11:12:12Z] <reedy@deploy2002> Finished scap sync-world: Backport for [[gerrit:1238291|Allow a selection of third-level wmcloud/toolforge domains for UrlShortener (T413211)]], [[gerrit:1239025|CommonSettings: Temporarily set $wgOATHUserHandlesTable = true (T416544)]] (duration: 06m 48s)

Reedy changed the task status from Open to In Progress.Thu, Feb 12, 11:56 AM
Reedy triaged this task as Medium priority.

Maintenance script presumably needs running?

That's been done too.

I took a look the tables and everything looks good. Looks like they've been fully populated and continue to update with new users.

All that remains now is to clean up the feature flag.

Change #1239023 merged by jenkins-bot:

[mediawiki/extensions/OATHAuth@master] Drop $wgOATHUserHandlesTable

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