Extension:CentralAuth

From MediaWiki.org
(Redirected from CentralAuth)
Jump to: navigation, search
MediaWiki extensions manual
Crystal Clear action run.png
CentralAuth

Release status: stable

CentralAuth administration demo screenshot.png
Implementation User identity, Database, Special page, API
Description Allows to merge accounts into global accounts
Author(s) Brion Vibber
MediaWiki 1.11+
License GPL
Download
Parameters

$wgCentralAuthDatabase
$wgCentralAuthAutoNew
$wgCentralAuthAutoMigrate
$wgCentralAuthStrict
$wgCentralAuthDryRun
$wgCentralAuthCookies
$wgCentralAuthCookieDomain
$wgCentralAuthCookiePrefix
$wgCentralAuthAutoLoginWikis

Added rights

centralauth-merge, centralauth-unmerge, centralauth-lock. centralauth-oversight, globalgrouppermissions, globalgroupmembership

Hooks used
AuthPluginSetup

AddNewAccount
AbortNewAccount
UserLoginComplete
UserLoadFromSession
UserLogout
UserLogoutComplete
GetCacheVaryCookies
GetPreferences
UserArrayFromResult
UserGetEmail
UserGetEmailAuthenticationTimestamp
UserSetEmail
UserSetEmailAuthenticationTimestamp
UserGetRights
UserSetCookies
UserLoadDefaults
getUserPermissionsErrorsExpensive
MakeGlobalVariablesScript
SpecialPasswordResetOnSubmit
RenameUserWarning
RenameUserPreRename
RenameUserComplete

Translate the CentralAuth extension if it is available at translatewiki.net

Check usage and version matrix; code metrics
Bugs: list open list all report

CentralAuth allows global accounts shared between projects. This extension adds seven new special pages—Special:AutoLogin (unlisted special page), Special:CentralAuth, Special:GlobalGroupMembership, Special:GlobalGroupPermissions, Special:WikiSets, Special:GlobalUsers and Special:MergeAccount.

Warning Warning: 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, this provides no solution to the single-sign-on feature (sign-in on one wiki, like wikipedia.org, automatically makes the user signed-in to e.g. a shared repository under a different, shared domain, like commons.wikimedia.org), nor global account locking.

CentralAuth development is closely tied to the MediaWiki core development trunk. Therefore, if you download the latest CentralAuth version, it may not work with older versions of MediaWiki. In general, for the best results, it may be a good idea to use a trunk version of MediaWiki when using this extension.

Installation[edit | edit source]

See the setup section below for prerequisites to using CentralAuth. Then follow these instructions when you are ready to activate CentralAuth:

  1. Download the latest snapshot and extract it to your extensions directory.
  2. Pick a database and create the CentralAuth database tables. You can use an existing database or create a new one; the extension by default uses a database named centralauth (see $wgCentralAuthDatabase below). use this database then run central-auth.sql.
    • If you use Extension:AntiSpoof you'll need to create a global spoofuser table (to block new usernames that look similar to existing usernames in any wiki). One way to do this is dump the spoofuser table from the local wiki's database and import it into the new $wgCentralAuthDatabase.
  3. Add require_once "$IP/extensions/CentralAuth/CentralAuth.php"; to LocalSettings.php for each of your wikis, or in another PHP file that is included in LocalSettings.php on each of your wikis.
  4. The extension should be now active.

Here are sample shell and SQL commands to create the centralauth database, copy the spoofuser table to it, and migrate existing user data to it. Replace $wgDBname and $wgDBuser with the values for your own wiki installation.

$ cd extensions/CentralAuth
$ mysql -u root -p
(enter password for root SQL user)
CREATE DATABASE centralauth;
USE centralauth;
SOURCE central-auth.sql
GRANT all on centralauth.* to '$wgDBuser'@'localhost';
quit
$ mysqldump -u $wgDBuser -p $wgDbName spoofuser > /tmp/spoofuser.temp
$ mysql -u $wgDBuser  -p centralauth < /tmp/spoofuser.temp
$ php maintenance/migratePass0.php
$ php maintenance/migratePass1.php

Walkthrough is a more user-friendly setup than the instructions below.

Setup[edit | edit source]

First, you'll need to configure your wiki 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). Follow the examples carefully. Make sure that you put the configuration code after the require_once "$IP/extensions/CentralAuth/CentralAuth.php"; line in LocalSettings.php. 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 databases enwiki, 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 the migratePass0.php and migratePass1.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 via Special:MergeAccount. Dry runs can be used for testing purposes.

To enable global groups, you will have to make an entry into the global_group_permissions table in your CentralAuth database, with ggp_group='steward' and (for access to the group management interface) ggp_permission=globalgrouppermissions. A sample query that is recommended to use is: INSERT INTO global_group_permissions (ggp_group,ggp_permission) VALUES ('steward','globalgrouppermissions'), ('steward','globalgroupmembership');. Then, run migrateStewards.php to promote local stewards to global steward status.

There are various settings you may wish to modify (e.g. whether to provide single sign-on across a whole domain) listed in CentralAuth.php. In particular, you will want to override the default value of $wgCentralAuthDatabase if your CentralAuth database is named something other than 'centralauth'. Make sure you put such settings after the require_once line in LocalSettings.php, e.g.:

require_once "$IP/extensions/CentralAuth/CentralAuth.php";
$wgCentralAuthDatabase = 'mycentralauthdatabase';

"SUL2" behavior[edit | edit source]


In July 2013 WMF changed its approach to logging users into multiple wikis. When configured for this new approach, after successful login and account creation CentralAuth redirects to Special: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;
$wgCentralAuthAutoNew = true;
$wgCentralAuthDatabase = 'centralauthDatabaseName'; // default is 'centralauth'
$wgCentralAuthAutoMigrate = true;
#$wgCentralAuthCookieDomain = '.example.org';
$wgCentralAuthAutoLoginWikis = array(
    # Mapping from domain name to wiki id for other wikis to automatically login into
);
 
# Create the local account on pageview, set false to require a local login to create it.
$wgCentralAuthCreateOnView = true;
 
# Activates the redirect to the "central login wiki"
$wgCentralAuthLoginWiki = 'WikiIdOfLoginWiki';
 
# Skips the "login success" page
$wgCentralAuthSilentLogin = true;
 
# Deprecated, will be removed soon.
$wgCentralAuthUseOldAutoLogin = false;

$wgCentralAuthLoginWiki is the id (usually the database-name) of the wiki to which CentralAuth will redirect on login and create account.

$wgCentralAuthAutoNew means account creation will create a new global account.

Simulating SUL2 behavior on a single-instance development machine[edit | edit source]

You can simulate this new behavior on a single-instance development machine. You can set $wgCentralAuthLoginWiki = $wgDBname) so CentralAuth makes its HTTP redirect requests to your same local wiki. This will not exercise central login properly, but will activate its "returnto" behavior. CentralAuth will still use its own 'centralauth' database to store global user names.

To determine the URL on the login wiki, CentralAuth uses WikiMap which assumes a wiki farm has been configured using $wgConf. Configuration setup (in SiteConfiguration.php) is very flexible; one way to set up a dummy single-wiki $wgConf in LocalSettings.php is:

// You can't just set wgConf values to the globals defined in Setup.php for your
// local wiki, because it hasn't run yet.  You could hard-code $wgConf settings
// here, but instead we set the wgConf values in a hook that runs later.
$wgHooks['SetupAfterCache'][] = function() {
    global $wgConf, $wgDBname,
        $wgServer, $wgCanonicalServer, $wgArticlePath;
    $wgConf->suffixes = array( $wgDBname );
    $wgConf->settings['wgServer'][$wgDBname] = $wgServer;
    $wgConf->settings['wgCanonicalServer'][$wgDBname] = $wgCanonicalServer;
    $wgConf->settings['wgArticlePath'][$wgDBname] = $wgArticlePath;
    return true;
};

This is in addition to the settings in #"SUL2" behavior above.

Cache issues[edit | edit source]

You do not need to use "CREATE TABLE centralauth.objectcache LIKE enwiki.objectcache" if you use MediaWiki version 1.19 or higher. The table is already created during the setup of your wiki.

Setting up CentralAuth will require all your wikis to use the same cache server. If they all use memcached it shouldn't be a problem, however if they are configured with the default setting (CACHE_NONE) and use different databases (or prefixes) it won't work (specifically, single logins do not work). Copy the objectcache table's structure to the CentralAuth database. This can be done by using a SQL command such as the following (which assumes your CentralAuth database is named centralauth and that your wiki is named enwiki):

CREATE TABLE centralauth.objectcache LIKE enwiki.objectcache

You also need to configure the following:

$wgSharedDB     = 'centralauth'; // or whatever database you use for central data
$wgSharedTables = array( 'objectcache' ); // remember to copy the table structure's to the central database first
$wgMainCacheType = CACHE_DB; // Tell mediawiki to use objectcache database instead of nothing

Use[edit | edit source]

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.

Functions[edit | edit source]

SUL[edit | edit source]

A user with an account on more than one wiki may use Special:MergeAccount to create their global user account, which can then be used on any wiki.

Global users[edit | edit source]

Screenshot of CentralAuth interface on Wikimedia, showing lock/hide interface.

A global account can be locked or hidden by a user with the centralauth-lock and centralauth-oversight permissions, respectively, given to the local 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, and logins fail with an "incorrect password" error. A hidden global account's username is not visible in any logs except the global account log.

Users with the centralauth-unmerge permission (again, 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.

Warning Warning: Account renames using Extension:Renameuser have to be done locally on every wiki.

Wiki sets[edit | edit source]

A wiki set is a group of wikis specified by a user with the globalgrouppermissions right. Sets can be opt-in (wikis are not in it by default) or opt-out (wikis are in it unless opted out).

Global user groups[edit | edit source]

Once you have enabled global user groups as described in the installation section, a migrated steward can use the Special: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 are not listed at Special:ListUsers, but instead Special:GlobalUsers. They are assigned by a user with the globalgroupmembership permission (by default the global group stewards), and give the specified rights to the user even if the local rights defined by $wgGroupPermissions do not do so.

Licensing and downloads[edit | edit source]

The extension is available under the GNU General Public License 2.0 or later, and can be downloaded from Git, or accessed via the web-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.

Hooks[edit | edit source]

This extension adds one new hook:

References[edit | edit source]

  1. [Mediawiki-l] CentralAuth problems: Help required
  2. [Mediawiki-l] Need help with CentralAuth

See also[edit | edit source]


Language: English  • 日本語