Page MenuHomePhabricator

Vector in consolidated user links mode shows account creation link instead of login link on private wiki
Closed, ResolvedPublic2 Estimated Story PointsBUG REPORT

Description

Compare officewiki on old Vector with officewiki on new Vector (while not logged in). The first has a "Log in" link, the second has a "Create account" link (which of course does not work for a private wiki).

Expected behavior:

  • Create account link is not displayed
  • Log in link stays within the user menu

Developer notes

The account creation link is unconditionally added.
It should check if the menu item exists.

Replicate with:

$wgHooks['SkinTemplateNavigation::Universal'][] = function ( $skinTemplate, &$links ) {
	unset( $links['user-menu']['createaccount'] );
};

The use case of extensions calling core or legacy hooks to unset the createaccount link in the personal toolbar is not being considered at this time. See T288428#7303233

Acceptance criteria

  • Private wikis do not show Create account link for anon users
  • Public wikis do show Create account link for anon users

QA steps

  • In LocalSettings.php, add the following config to test whether Create account link shows in the personal menu:
$wgGroupPermissions['*']['createaccount'] = false;
  • Without above config, the Create account link should be visible.
  • With above config, the Create account link should not be visible.

QA Results - Beta

ACStatusDetails
1T288428#7324878
2T288428#7324878

QA Results - Prod

ACStatusDetails
1T288428#7324894
2T288428#7324894

Event Timeline

Change 713505 had a related patch set uploaded (by Clare Ming; author: Clare Ming):

[mediawiki/skins/Vector@master] Don't show create account link on private wikis

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

cjming moved this task from Doing to Code Review on the Web-Team-Backlog (Kanbanana-FY-2021-22) board.
cjming subscribed.

Change 714124 had a related patch set uploaded (by Clare Ming; author: Clare Ming):

[mediawiki/core@master] Add member variable, functions to SkinTemplate

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

Per discussion on https://gerrit.wikimedia.org/r/c/mediawiki/skins/Vector/+/713505 + https://gerrit.wikimedia.org/r/c/mediawiki/core/+/714124, for now we're going to ignore the possible use case of extensions disabling the Create account link from core hooks (SkinTemplate::runOnSkinTemplateNavigationHooks()).

To address the immediate use case, we'll just check if config disables account creation during Vector's Hooks::onSkinTemplateNavigation().

For future reference, if/when we do need a way for extensions to hook into navigation to disable account creation (i.e. OAuth), we can revisit implementing a generic solution to make private property/methods on SkinTemplate for tracking this and create a new hook (i.e. Hooks::run( 'SkinTemplateCreateAccountAllowed' );). The preliminary proof-of-concept is captured in the following patchsets:

Change 714124 abandoned by Clare Ming:

[mediawiki/core@master] Add member variable, functions to SkinTemplate

Reason:

Generic solution not needed at this time. We can revisit if providing a hook to disable account creation is needed. See https://phabricator.wikimedia.org/T288428#7303233

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

In general, using skin hooks to hide the account creation link seems like a strange thing for an extension to do. Typically they would do something to actually prevent account creation (change permissions, set a custom authentication provider etc) so the important thing to do would be to make sure the link does not show up if anons do not have the createaccount permission or AuthManager::canCreateAccounts() is false - I think those are the only reliable ways to prevent account creation.

@Tgr the use case we found was in the OpenID extension which removes create account link:
https://gerrit.wikimedia.org/g/mediawiki/extensions/OpenID/+/b96f42976effec9094eadafde34b15f1ccfc088c/includes/OpenIDHooks.php#105

As you say I think there are more reliable ways and our plan is no longer to support this.

Some kind of hook might be useful for OpenID to explicitly disable, but it doesn't seem a hardship to simply update its install instructions (and we are not looking into this for now).

IMO the OpenID extension generally has a very legacy approach to authentication (it was written a long time ago), I think if it is updated to use AuthManager it won't need any new way of hiding the link.

What I'd check for compatibility is PluggableAuth which is well-maintained and I think fairly widely used. It doesn't hide the account creation link manually, but it does hide the logout link under certain circumstances so if that's also affected that might be worth a heads-up to the maintainer.

Thanks for the insight @Tgr. Logout is not impacted by this change, only the create account and login links.

Change 713505 merged by jenkins-bot:

[mediawiki/skins/Vector@master] Do not show create account link for private wikis.

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

Test Result - Beta

Status: ✅ PASS
Environment: beta (local)
OS: macOS Big Sur
Browser: Chrome
Device: MBP
Emulated Device: NA

Test Artifact(s):

QA Steps

In LocalSettings.php, add the following config to test whether Create account link shows in the personal menu:
$wgGroupPermissions['*']['createaccount'] = false;

✅ AC1: Without above config, the Create account link should be visible.

Screen Shot 2021-09-01 at 6.58.47 AM.png (307×981 px, 63 KB)

✅ AC2: With above config, the Create account link should not be visible.
Screen Shot 2021-09-01 at 7.09.10 AM.png (307×981 px, 62 KB)

Edtadros subscribed.

Test Result - Prod

Status: ✅ PASS
Environment: officewiki
OS: macOS Big Sur
Browser: Chrome
Device: MBP
Emulated Device: NA

Test Artifact(s):

QA Steps

In LocalSettings.php, add the following config to test whether Create account link shows in the personal menu:
$wgGroupPermissions['*']['createaccount'] = false;

⬜ AC1: Without above config, the Create account link should be visible.
Not testable
✅ AC2: With above config, the Create account link should not be visible.

Screen Shot 2021-09-01 at 7.18.00 AM.png (503×1 px, 450 KB)