CentralAuth allows merging several existing separate account systems into one global account system.
| CentralAuth was designed specifically for Wikimedia projects which already had millions of accounts that needed to be merged into a global table. If you are starting a new wiki farm from scratch and have no need to merge existing accounts into a global table, it is much easier to set up global accounts using$wgSharedDB rather than using CentralAuth.[1][2] However, If you end up using this extension on a third-party wiki, it is likely that you will end up having to troubleshoot complex issues that potentially require diving into the source code to resolve. You have been warned. |
| CentralAuth does not work well with SQLite-based setups, such asQuickstart. SeeT382432. |
See thesetup section below for prerequisites to using CentralAuth.Then follow these instructions when you are ready to activate CentralAuth:
extensions directory.$wgVirtualDomainsMapping['virtual-centralauth'] below.) Use this database then runtables-generated.sql.spoofuser table (to block new usernames that look similar to existing usernames in any wiki). One way to do this is dump thespoofuser table from the local wiki's database and import it into the new$wgVirtualDomainsMapping['virtual-centralauth'].wfLoadExtension('CentralAuth'); to yourLocalSettings.php for each of your wikis, or in another PHP file that is included inLocalSettings.php on each of your wikis.Here are sample shell and SQL commands to create thecentralauth database, copy thespoofuser table to it, and migrate existing user data to it.Replace $wgDBname and $wgDBuser with the values for your own wiki installation credentials.
Create the new database (Remember this step is optional, you can instead use one of your existing databases, in which case skip to the create tables step):
$cdextensions/CentralAuth$mysql-uroot-p(enter password for root SQL user)
CREATEDATABASEcentralauth;USEcentralauth;GRANTalloncentralauth.*to'$wgDBuser'@'localhost';quit
The following assumes your present working directory is your MediaWiki installation (not your CentralAuth directory).Create the central auth tables (usingsql.php is preferred).
phpmaintenance/run.phpsql--wikidbcentralauthextensions/CentralAuth/schema/<db_type>/tables-generated.sql
If AntiSpoof is installed, create the table via (Alternatively, you can copy an existing AntiSpoof table if you want to keep previous entries):
phpmaintenance/run.phpsql--wikidbcentralauthextensions/AntiSpoof/sql/<db_type>/tables-generated.sql
Run the user migration scripts
$phpmaintenance/run.phpCentralAuth:migratePass0.php$phpmaintenance/run.phpCentralAuth:migratePass1.php
CentralAuth is designed for large wiki farms who run database updates manually in order to enable zero-downtime upgrades.For that reason, the CentralAuth database will not be updated with the usual upgrade process.Third-party users are expected to follow CentralAuth development and apply database migrations manually instead.
| A central login wiki (see#SUL2) or a shared auth domain (see#SUL3) is required if you want to have a universal sign-on across different primary domains (i.e. if your wikis are not under subdomains of the same domain). |
First, you'll need to configure yourwiki family using$wgConf, or CentralAuth can't be used for your wiki family.This includes setting$wgLocalDatabases and assigning it to$wgConf->wikis, and$wgConf->settings (minimum is$wgCanonicalServer,$wgServer and$wgArticlePath).Followthe examples carefully.If you are creating a new wiki family, bear in mind that it may be easier if the databases for the wikis in each group have the same suffix (e.g. hypothetical databasesenwiki,dewiki,frwiki,etc., pertaining to wikis belonging to the same group, all have the suffix "wiki").
After installing the extension, you have to gather some data in the CentralAuth database.In order to retroactively set up global accounts, you will have to run themigratePass0.php andmigratePass1.php scripts.The first one stores information about your wikis in the CentralAuth database, while the second one uses automatic migration heuristics to generate global accounts.A user can merge their accounts manually viaSpecial:MergeAccount.Dry runs can be used for testing purposes.
To enable global groups, you will have to make an entry into theglobal_group_permissions table in your CentralAuth database, withggp_group='steward' and (for access to the group management interface)ggp_permission=globalgrouppermissions.A sample query that is recommended to use is:
INSERTINTOglobal_group_permissions(ggp_group,ggp_permission)VALUES('steward','globalgrouppermissions'),('steward','globalgroupmembership');
Then, promote some users into stewards:
INSERTIGNOREINTOglobal_user_groups(gug_user,gug_group)VALUES((SELECTgu_idFROMglobaluserWHEREgu_name='Admin'),'steward');
There are various settings you may wish to modify (e.g. whether to provide single sign-on across a whole domain) listed inCentralAuth.php.In particular, you will want to set a value for$wgVirtualDomainsMapping['virtual-centralauth'].Make sure you put such settings after thewfLoadExtension line inLocalSettings.php,e.g.:
wfLoadExtension('CentralAuth');$wgVirtualDomainsMapping['virtual-centralauth']=['db'=>'centralauth'];
| As all logged in users will have a session in the central login wiki, you are recommended to set up a new wiki with as few extensions installed as possible (not using an existing wiki for this purpose).This will reduce the risk for XSS vulnerabilities. |
Universal sign-on may be broken in newer Google Chrome versions due to SameSite cookie policy. To fix it, you need to add:$wgCookieSameSite="None";$wgUseSameSiteLegacyCookies=true; |
In July 2013, Wikimedia changed its approach to logging users into multiple wikis.When configured for this new approach, after successful login and account creation CentralAuth redirects toSpecial:CentralLogin/start?token=somevalue on a "central login wiki", which sets cookies on that wiki and then redirects back to the logged-into wiki.It omits the "login/account creation success" page, instead redirecting back to the "returnto" page that the user was originally on.It places 1x1 pixel images in the footer of that page, in place of the icons formerly used on the "login/account creation success" page.
The settings for this are, roughly,
# General CentralAuth configuration$wgCentralAuthCookies=true;// default is to use the local wiki database$wgVirtualDomainsMapping['virtual-centralauth']=['db'=>'centralauthDatabaseName'];$wgCentralAuthAutoMigrate=true;$wgCentralAuthAutoLoginWikis=[# Mapping from domain name to wiki id for other wikis to automatically login into'enwiki.mediawiki.mwdd.localhost'=>'enwiki',];# Activates the redirect to the "central login wiki"$wgCentralAuthLoginWiki='WikiIdOfLoginWiki';
$wgCentralAuthLoginWiki is the ID (usually the database-name) of the wiki to which CentralAuth will redirect on login and create account actions.
In 2025 the Wikimedia cluster setup was changed so that authentication happens (e.g. users input their passwords) on a shared domain, instead of each wiki's individual domains.The shared domain can be configured to serve each of the wikis in the farm.This was motivated by changes to browser cookies handling that might prevent cookies from being set during the redirect through a central wiki.SeeSUL3 for more details.
To configure your wiki farm to use SUL3:
sites table or$wgConf (see#Setup).$wgCentralAuthLoginWiki and$wgLocalDatabases should also be set. Other parts of CentralAuth are somewhat tolerant if this is missing, but SUL3 will crash.http://localhost (optionally with a port), note that all localhost subdomains resolve to your machine, so you can start using e.g.http://auth.localhost andhttp://wiki.localhost without any configuration needed.$wgCentralAuthSharedDomainCallback to return your new domain. Note that this is a callback function, not a string.$wgCentralAuthEnableSul3 = true;You might need to adjust some MediaWiki config settings to support this:
$wgServer and$wgCanonicalServermust be conditionally set to the auth domain when accessing your wiki through the auth domain, otherwise you will get a redirect loop when trying to log in. CentralAuth reads the "real" canonical server from the wiki farm configuration defined in step 1.$wgCentralAuthSharedDomainCallback to add a path prefix after the domain name that depends on the wiki, configure your server to serve the right wiki depending on that prefix, and conditionally adjust$wgScriptPath,$wgArticlePathetc. to match. This is tricky to get right, so if you're setting up a local environment for development, don't bother.$wgCentralAuthCookiePrefix when accessing your wiki through the auth domain is a good way to avoid cookie name conflicts.Below is a minimal configuration to run CentralAuth with SUL3 on a single-wiki "farm" on your development machine:
// Minimal setup for a single-wiki "farm"$wgConf->wikis=[$wgDBname];$wgConf->suffixes[]='';$wgConf->settings=['wgServer'=>['default'=>'http://wiki.localhost:8080'],'wgArticlePath'=>['default'=>'/wiki/$1'],];// Misc settings needed by CentralAuth$wgCentralAuthLoginWiki=$wgDBname;$wgLocalDatabases=[$wgDBname];// Enable CentralAuth SUL3$wgCentralAuthSharedDomainCallback=fn()=>'http://auth.localhost:8080';$wgCentralAuthEnableSul3=true;// Point $wgServer to whichever domain the wiki was accessed through$wgCanonicalServer=$wgServer=MediaWiki\Request\WebRequest::detectServer(true);if($wgServer==='http://auth.localhost:8080'){// Conditional config for the shared auth domain goes here}
For best results, it is recommended to use memcached or a more persistent cache.If you have only a single server, accelerator caches (CACHE_ACCEL) like APCu can also work, but do not use them if you have multiple servers.If you have no cache set up (i.e.CACHE_NONE) for$wgMainCacheType, or are usingCACHE_DB, then you need to make sure all your wikis use the same caching table.
By default, each wiki in your wiki farm will use theobjectcache table in its own database (with its own db prefix) when$wgMainCacheType is set toCACHE_NONE orCACHE_DB.To make this work with CentralAuth, we need to tell the wikis to use a central cache table.
If you want to make a central caching table in thecentralauth database (and assuming one of your existing wikis has a database name ofenwiki), run code like the following to copy the table to your other database (assuming you have an installed wiki with database called "enwiki" and another database called "centralauth"):
CREATETABLEcentralauth.objectcacheLIKEenwiki.objectcache;
Then add the following config to all wikis to tell them to use the central table instead of their own table:
$wgSharedDB='centralauth';// or whatever database you use for central data$wgSharedTables=['objectcache'];// remember to copy the table structure's to the central database first$wgCentralAuthSessionCacheType=CACHE_DB;// Tell mediawiki to use objectcache database for central auth.
When runningPHPUnit tests locally with your wiki farm and do not want them to fail due to an attempt to clone database tables with the shared tables config above, use:
if(defined('MW_PHPUNIT_TEST')){$wgSharedTables=[];}else{$wgSharedTables=['objectcache'];}
Since 2023, CentralAuth does not support mixed-protocol HTTP/HTTPS wikis, only pure-HTTPS wikis (with$wgForceHTTPS set totrue) and pure-HTTP wikis (primarily for local testing).Seeissue T348852.
Since MediaWiki 1.41, you can configure databasevirtual domains mapping for CentralAuth, and thisreplaced$wgCentralAuthDatabase.To setup virtual domains mapping with CentralAuth, use:
// 'centralauth' is the name of the your CentralAuth database.$wgVirtualDomainsMapping['virtual-centralauth']=['db'=>'centralauth'];
| parameter | default | comment |
|---|---|---|
(deprecated)$wgCentralAuthDatabase | null | Database name you keep central auth data in. If this is not on the primary database connection, don't forget to also set up To use a database with a table prefix, set this variable to " This setting has been deprecated, use virtual domains mapping as described above. |
$wgCentralAuthAutoMigrate | false | Iftrue, existing unattached accounts will be automatically migrated if possible at first login.Any new account creations will be required to attach. If |
$wgCentralAuthAutoMigrateNonGlobalAccounts | false | Iftrue, existing unattached accounts where no global account exists will be compared to see if a merge can be made based on passwords and emails with no clashes (all accounts merge).This was formerly controlled by |
$wgCentralAuthStrict | false | Iftrue, remaining accounts which have not been attached will be forbidden from logging in until they are resolved. |
$wgCentralAuthDryRun | false | Iftrue, merging won't actually be possible through the Special:MergeAccount interface. |
$wgCentralAuthCookies | false | Iftrue, global session and token cookies will be set alongside the per-wiki session and login tokens when users log in with a global account.This allows other wikis on the same domain to transparently log them in. |
$wgCentralAuthLoginWiki | false | Database name of a central login wiki. This is an alternative to directly setting cross-domain cookies for each wiki in$wgCentralAuthAutoLoginWikis. If set, a single login wiki will use a session/cookie to handle unified login sessions across wikis.On login, users will be redirected to the login wiki's Special:CentralLogin/login page and then redirected to Special:CentralLogin back on the originating wiki.In the process, the central login wiki cookie and session will be set.As the user accesses other wikis, the login wiki will be checked via JavaScript to check login status and set the local session and cookies. This requires |
$wgCentralAuthSharedDomainCallback | false | Callback that takes a wiki ID and returns the URL prefix for the shared authentication domain without a trailing slash. This should use the same domain and scheme on every wiki of the CentralAuth wiki farm, with a path prefix that specifies the given wiki. A local URL appended to this prefix must be routed the same way as a local URL on the current wiki. This is used to share a central cookie between wikis while allowing the cookie-related UI (such as the login and signup page) to behave like any specific wiki in the farm. If unset, this mechanism will not be used. |
$wgCentralAuthEnableSul3 | false | EnablesSUL3 mode. Requires$wgCentralAuthSharedDomainCallback to be configured first. |
$wgCentralAuthRestrictSharedDomain | false | Restrict wiki functionality to authentication only when the current domain matches the domain of CentralAuthSharedDomainCallback. Enable when using a shared login domain. Disable when the login domain is a standalone wiki. |
$wgCentralAuthSul3SharedDomainRestrictions | complex array | Additional allowed/disallowed features when on the SUL3 central login domain. Defaults are stored inSharedDomainHookHandler::DEFAULT_RESTRICTIONS. |
$wgCentralAuthCookieDomain | '' | Domain to set global cookies for. For instance, |
$wgCentralAuthCookiePrefix | 'centralauth_' | Prefix for CentralAuth global authentication cookies. |
$wgCentralAuthCookiePath | '/' | Path for CentralAuth global authentication cookies. Set this variable if you want to restrict cookies to a certain path within the domain specified by$wgCentralAuthCookieDomain. |
$wgCentralAuthAutoLoginWikis | [] | List of wiki IDs which should be called on login to try to set third-party cookies for the global session state. The wiki ID is typically the database name, except when table prefixes are used, in which case it is the database name, a hyphen separator, and then the table prefix. This allows a farm with multiple second-level domains to set up a global session on all of them by hitting one wiki from each domain (en.wikipedia.org, en.wikinews.org,etc.). Done by accessing If empty, no other wikis will be hit. The key should be set to the cookie domain name. |
$wgCentralAuthAutoCreateWikis | [] | List of wiki IDs on which an attached local account should be created automatically when the global account is created. The wiki ID is typically the database name, except when table prefixes are used, in which case it is the database name, a hyphen separator, and then the table prefix. |
$wgCentralAuthLoginIcon | false | Local filesystem path to the icon returned bySpecial:CentralAutoLogin should be a 20x20px PNG. |
$wgCentralAuthPrefsForUIReload | ['skin','language','thumbsize','underline','stubthreshold','showhiddencats','justify','numberheadings','editondblclick','editsection','editsectiononrightclick','usenewrc','extendwatchlist'] | User preferences for which we should recommend reloading the page after a successful central login query. If you need to do something more complicated than just |
$wgCentralAuthRC | [] | Array of settings for sending the CentralAuth events to the RC Feeds.
|
$wgCentralAuthWikisPerSuppressJob | 10 | Size of wikis handled in one suppress user job. Keep in mind that one wiki requires~10 queries. |
$wgCentralAuthReadOnly | false | Like$wgReadOnly, used to set extension to database read only mode.
|
$wgCentralAuthEnableGlobalRenameRequest | false | Feature flag forSpecial:GlobalRenameRequest.
|
$wgCentralAuthGlobalPasswordPolicies | [] | Global password policies. These are applied like local password policies, the strongest policy applicable to a user is used. Policies can apply to either a local group (if the user is a member of that group on any wiki, the policy will apply to that user) or global group.
|
$wgGlobalRenameDenylist | null | A list of users who won't be allowed to create new global rename requests through Special:GlobalRenameRequest. There are two ways to set it:
You can use the exact names or regular expressions.
|
$wgCentralAuthGlobalBlockInterwikiPrefix | "global" | When globally suppressing a user, a block against this user is inserted in all wikis. CentralAuth will set the author of theses blocks as$wgCentralAuthGlobalBlockInterwikiPrefix>(user-who-made-the-suppression's nickname). For example, if$wgCentralAuthGlobalBlockInterwikiPrefix="Admins";, and Joe suppresses John, all wikis will show inBlockList a block against John made byAdmins>Joe.
|
Allows for a single-user login (SUL) system using MediaWiki's AuthPlugin system.User creation and login is done globally using one central user table across all wikis.Note that local user accounts are automatically created on account creation/login however.
This extension also implements global user groups, to which global accounts can belong to.
CentralAuth defines several new user rights:
| User right | Abilities | Default group | Status |
|---|---|---|---|
centralauth-createlocal | Forcibly create a local account for a global account | Stewards and sysops | Active in MW 1.36+ |
centralauth-lock | Prevent users from logging in on any wiki | Stewards | Active |
centralauth-suppress | Suppress or unhide global accounts | Stewards | Active |
centralauth-rename | Rename global accounts | Stewards | Active |
centralauth-unmerge | Unmerge global accounts from a local account | Stewards | Active |
centralauth-merge | Merge all CentralAuth accounts globally | All users | Active; usually automatic |
globalgrouppermissions | Manage permissions of global groups | Global Stewards | Active; not assigned to local stewards by default |
globalgroupmembership | Edit membership to global groups | Global Stewards | Active; not assigned to local stewards by default |
A user with an account on more than one wiki may useSpecial:MergeAccount to create their global user account, which can then be used on any wiki. Users with thecentralauth-unmerge permission (given to stewards by default) can undo a merging of a global account, where the passwords are all reset back to the pre-merge setting.User accounts can now also be renamed globally.

A global account can belocked orhidden by a user with thecentralauth-lock andcentralauth-suppress permissions, respectively, given to thelocal group 'stewards' by default.A locked global account will be immediately logged out of any session on any wiki it is currently logged in to.A hidden global account's username is not visible in any logs except the global account log.
Awiki set is a group of wikis specified by a user with theglobalgrouppermissions right.Sets can beopt-in (wikis are not in it by default) oropt-out (wikis are in it unless opted out).
Once you have enabled global user groups as described in the installation section, a migrated steward can use theSpecial:GlobalGroupPermissions interface to configure global user groups, and their rights.A global user group is active on all wikis (the users in it have its rights on all the wikis) by default, unless the group has been specified to only be active on a specific wiki set (the users in the group only have the rights if they are on a wiki in the set).Global group permissions arenot listed atSpecial:ListUsers, but insteadSpecial:GlobalUsers.They are assigned by a user with theglobalgroupmembership permission (by default the global groupstewards), and give the specified rights to the user even if the local rights defined by$wgGroupPermissions do not do so.
The extension is available under the GNU General Public License 2.0 or later, and can bedownloaded from Git, or accessed via theweb-based viewer.
The software is provided as-is.Updates will be made according to the needs of Wikimedia wikis; or where critical vulnerabilities are discovered.
$wgSharedDB| This extension is being used on one or moreWikimedia projects. This probably means that the extension is stable and works well enough to be used by such high-traffic websites. Look for this extension's name in Wikimedia'sCommonSettings.php andInitialiseSettings.php configuration files to see where it's installed. A full list of the extensions installed on a particular wiki can be seen on the wiki'sSpecial:Version page. |
| This extension is included in the following wiki farms/hosts and/or packages:This is not an authoritative list. Some wiki farms/hosts and/or packages may contain this extension even if they are not listed here. Always check with your wiki farms/hosts or bundle to confirm. |