Page MenuHomePhabricator

Update requireLogin to use requireNamed in OATHAuth special pages
Closed, ResolvedPublic

Description

In T344276, we want to make sure SpecialPage::requireLogin is used only when temporary accounts should be allowed to use the special page. As for now, we want to treat temporary users just like anonymous or IP users in most situations.

For the MediaWiki-extensions-OATHAuth extension, we should disallow temporary accounts from using the following special pages:

  • src/Special/DisableOATHForUser.php - Because this should only be done by users with advanced rights
  • src/Special/OATHManage.php - Because 2FA for temporary accounts would not be effective (as you cannot log into a temporary account)

Code Search Link

Event Timeline

It looks like Special:DisableOATHForUser checks if the user is an administrator and Special:OATHManage checks if the user has the user role (temporary users don't have this), so as of right now neither of these pages render for temporary users. If that's the intended outcome then nothing needs to change.

Speaking of improving temporary users support for this extension, I did notice one thing. The user search input on Special:DisableOATHForUser should probably be configured to filter out temporary users since temporary users cannot have two-factor configured in the first place. I don't think it makes sense to autofill them there.

kostajh subscribed.

It looks like Special:DisableOATHForUser checks if the user is an administrator and Special:OATHManage checks if the user has the user role (temporary users don't have this), so as of right now neither of these pages render for temporary users. If that's the intended outcome then nothing needs to change.

Sounds good.

Speaking of improving temporary users support for this extension, I did notice one thing. The user search input on Special:DisableOATHForUser should probably be configured to filter out temporary users since temporary users cannot have two-factor configured in the first place. I don't think it makes sense to autofill them there.

That makes sense, could you make a patch for this please?

Amdrel changed the task status from Open to In Progress.Aug 21 2024, 5:48 PM

Change #1064447 had a related patch set uploaded (by Amdrel; author: Amdrel):

[mediawiki/extensions/OATHAuth@master] Filter temporary accounts from dropdown on Special:DisableOATHForUser

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

We should require named users for both special pages, because 2FA is only relevant to accounts which can be logged in to. This does not include temporary accounts.

We also need to update the special pages to require a named user per the task description, but the patch attached here should be good to go.

Dreamy_Jazz renamed this task from Update requireLogin() for temp users on OATHAuth extension to Update requireLogin to use requireNamedUsers in OATHAuth special pages.Sep 19 2024, 10:01 AM
Dreamy_Jazz renamed this task from Update requireLogin to use requireNamedUsers in OATHAuth special pages to Update requireLogin to use requireNamed in OATHAuth special pages.
Dreamy_Jazz updated the task description. (Show Details)

Change #1064447 merged by jenkins-bot:

[mediawiki/extensions/OATHAuth@master] Filter temporary accounts from dropdown on Special:DisableOATHForUser

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

Change #1075317 had a related patch set uploaded (by Amdrel; author: Amdrel):

[mediawiki/extensions/OATHAuth@master] Add 'requireNamedUser' checks to all Special Pages

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

Change #1075317 merged by jenkins-bot:

[mediawiki/extensions/OATHAuth@master] Add 'requireNamedUser' checks to all Special Pages

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

Djackson-ctr subscribed.

QA has been completed, and the new code change(s) are functioning as expected (The Username textfield on Special:DisableOATHForUser will not autofill/nor submit Temporary Account Usernames, also Special:OATHManage and Special:DisableOATHForUser have been changed to use the logic for requireNamedUser).

We missed the Special:VerifyOATHForUser page. This page does not prevent a user inputting a temporary account and checking the whether the temporary account has 2FA enabled. Considering that temporary accounts cannot be logged in to, we should make the form not do anything for a temporary account and also not suggest temporary account usernames in the dropdown.

Actually, I'll re-open T326925 as that's a more relevant ticket.

Change #1090841 had a related patch set uploaded (by Pmiazga; author: Pmiazga):

[mediawiki/extensions/OATHAuth@master] feat: exclude temporary accounts from Disable and Verify OATH pages

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

Change #1090841 merged by jenkins-bot:

[mediawiki/extensions/OATHAuth@master] feat: exclude temporary accounts from VerifyOATHForUser special page

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