Page MenuHomePhabricator

[S] Add a temp user type to UserDef::PARAM_ALLOWED_USER_TYPES
Closed, ResolvedPublic1 Estimated Story Points

Description

Action and REST APIs can specify allowed user types for a parameter, via UserDef::PARAM_ALLOWED_USER_TYPES. We should add a temp user type to this list:

UserDef::PARAM_ALLOWED_USER_TYPES
  'name': User names are allowed.
  'ip': IP ("anon") usernames are allowed.
  'cidr': IP ranges are allowed.
  'interwiki': Interwiki usernames are allowed.
  'id': Allow specifying user IDs, formatted like "#123".

We'll need to update UserDef::processUserto recognize a temporary user (say, 'temp'?) as different from a named user ('name').

Note
This will mean that APIs that want to be usable by temporary users will need to be updated. This will require extra work (compared to just assuming temporary users are in either the 'ip' or 'name' buckets). This decision was arrived at in T337103: Decide a standard approach for classifying temporary, IP and registered users, and Trust and Safety Product Team will communicate this work ahead of enabling temporary account auto-creation.

Event Timeline

Tchanders renamed this task from Add a temp user type to UserDef::PARAM_ALLOWED_USER_TYPES to [S] Add a temp user type to UserDef::PARAM_ALLOWED_USER_TYPES.Nov 7 2023, 4:31 PM

Change 978044 had a related patch set uploaded (by STran; author: STran):

[mediawiki/core@master] Add temporary user type to UserDef

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

Change 978533 had a related patch set uploaded (by Tchanders; author: Tchanders):

[mediawiki/core@master] Add 'temp' to allowed user types in various APIs

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

Change 978534 had a related patch set uploaded (by Tchanders; author: Tchanders):

[mediawiki/extensions/CentralAuth@master] ApiQueryGlobalUserInfo: Allow 'temp' type for 'user' param

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

This is a breaking change as described in the release notes:

UserDef::PARAM_ALLOWED_USER_TYPES now differentiates between temporary account
usernames and user accounts. Any endpoints that want temp users to be
valid but were passing a name through will break. Temp users must now be
explicitly allowed.

Existing are updated in the other patches linked to this task, by:

  1. Searching https://codesearch.wmcloud.org/search/?q=UserDef%3A%3APARAM_ALLOWED_USER_TYPES&files=&excludeFiles=&repos=
  2. Updating those params that should allow the 'temp' type (instances were found in core and CentralAuth) - and leaving those that shouldn't alone.

Change 978044 merged by jenkins-bot:

[mediawiki/core@master] Add temporary user type to UserDef

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

Change 978534 merged by jenkins-bot:

[mediawiki/extensions/CentralAuth@master] ApiQueryGlobalUserInfo: Allow 'temp' type for 'user' param

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

Change 978533 merged by jenkins-bot:

[mediawiki/core@master] Add 'temp' to allowed user types in various APIs

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

dom_walden subscribed.

I tried calling a few APIs which have parameters of type user, passing named and temporary users, on wikis with and without temporary users enabled.

Passing a temporary username to a user parameter which accepts temp users works fine.

The only difference I can see when calling an API is when the user parameter accepts only named users and you are on a wiki with temporary users enabled. If you try to pass a temporary username, it will return something like:

{
    "error": {
        "code": "baduser",
        "info": "Invalid value \"*Unregistered #nnn\" for user parameter \"wlowner\".",
        ...

On a wiki with temporary users disabled, temporary usernames are counted as named users so the APIs work as they did previously.

Test environments: https://en.wikipedia.beta.wmflabs.org and https://de.wikipedia.beta.wmflabs.org MediaWiki 1.42.0-alpha (6c07e2a) 02:15, 12 December 2023.

@STran can this ticket be closed?

Yes - thanks.