From mediawiki.org
Jump to navigation Jump to search
This page is a translated version of the page Extension:CentralAuth and the translation is 29% complete.
MediaWiki 拡張機能マニュアル
OOjs UI icon advanced-invert.svg
リリースの状態: 安定
CentralAuth administration demo screenshot.png
実装 利用者識別 , データベース , 特別ページ , API
説明 アカウントをグローバルアカウントに統合できるようにする
作者 Brion Vibber
互換性ポリシー Snapshots releases along with MediaWiki. Master is not backward compatible.
MediaWiki 1.29
データベースの変更 はい
テーブル globalnames
ライセンス GNU 一般公衆利用許諾書 2.0 以降
  • $wgCentralAuthAutoLoginWikis
  • $wgCentralAuthUseEventLogging
  • $wgCentralAuthCookiePath
  • $wgCentralAuthReadOnly
  • $wgCentralAuthAutoMigrate
  • $wgCentralAuthEnableUserMerge
  • $wgCentralAuthEnableGlobalRenameRequest
  • $wgCentralAuthCreateOnView
  • $wgCentralAuthGlobalPasswordPolicies
  • $wgCentralAuthCookieDomain
  • $wgCentralAuthLockedCanEdit
  • $wgCentralAuthPreventUnattached
  • $wgCentralAuthWikisPerSuppressJob
  • $wgCentralAuthCookies
  • $wgOverrideCentralIdLookupProvider
  • $wgCentralAuthRC
  • $wgCentralAuthGlobalBlockInterwikiPrefix
  • $wgCentralAuthAutoMigrateNonGlobalAccounts
  • $wgCentralAuthDatabase
  • $wgCentralAuthDryRun
  • $wgCentralAuthCookiesP3P
  • $wgCentralAuthTokenCacheType
  • $wgCentralAuthEnableUsersWhoWillBeRenamed
  • $wgGlobalRenameBlacklistRegex
  • $wgCentralAuthLoginIcon
  • $wgCentralAuthStrict
  • $wgCentralAuthOldNameAntiSpoofWiki
  • $wgCentralAuthLoginWiki
  • $wgGlobalRenameBlacklist
  • $wgCentralAuthSessionCacheType
  • $wgCentralAuthCheckSULMigration
  • $wgDisableUnmergedEditing
  • $wgCentralAuthPrefsForUIReload
  • $wgCentralAuthAutoCreateWikis
  • $wgCentralAuthCookiePrefix
  • centralauth-createlocal
  • centralauth-merge
  • centralauth-unmerge
  • centralauth-lock
  • centralauth-oversight
  • globalgrouppermissions
  • globalgroupmembership
  • centralauth-rename
  • centralauth-usermerge
translatewiki.net で翻訳を利用できる場合は、CentralAuth 拡張機能の翻訳にご協力ください

使用状況とバージョン マトリクスを確認してください。

問題点 未解決のタスク · バグを報告

CentralAuthはグローバルアカウントを複数のプロジェクトで共有できるようにします。 この拡張機能は7個の新しい特別ページを追加します: Special:AutoLogin (一覧に表示されない特別ページ), Special:CentralAuth, Special:GlobalGroupMembership, Special:GlobalGroupPermissions, Special:WikiSets, Special:GlobalUsers, Special:MergeAccount


警告 警告: CentralAuth は、共通認証用テーブルに統合する必要があるアカウントが既に何百万も存在するウィキメディアのプロジェクト群のために特化して設計されたものです。

一から新たなウィキを立ち上げようとしていて、既存アカウントを共通認証用テーブルに統合する必要がない場合、CentralAuth を使うより $wgSharedDB を使って共通認証アカウントを設定した方がずっと簡単です。[1][2]

However, $wgSharedDB is only useful for preventing conflicts of username creations, and does not handle anything such as universal sign-on (instead, users are required to sign in to each wiki), or cross-cluster account rights and management.



CentralAuth をインストールして使用できるようにするための前提条件は、以下の セットアップ節を参照してください。 CentralAuth を有効にする準備ができたら、以下の指示に従ってください:

  1. 最新のスナップショットをダウンロードして、extensionsディレクトリに展開します。
  2. データベースを選択し、CentralAuthデータベーステーブルを作成してください。 既存のデータベースを使用しても、データベースを作成してもいいです; 拡張機能の使用する規定のデータベースの名前はcentralauthです。 このデータベースを使用して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). これを行う方法は、ローカルwikiのデータベースからspoofuserのテーブルのダンプを作成して、新しい$wgCentralAuthDatabaseにインポートすることです。
  3. Add wfLoadExtension( 'CentralAuth' ); 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. これで拡張機能が有効になるはずです。

ここでは、CentralAuthのデータベースを作成し、spoofuserテーブルをコピーして、既存のユーザーデータを中央Wikiへ移行するためのサンプルシェルとSQLコマンドを紹介します。 Replace $wgDBname and $wgDBuser with the values for your own wiki installation.

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):

$ cd extensions/CentralAuth
$ mysql -u root -p
(enter password for root SQL user)
CREATE DATABASE centralauth;
USE centralauth;
GRANT all on centralauth.* to '$wgDBuser'@'localhost';

The following assumes your present working directory is your MediaWiki installation (not your CentralAuth directory). 中央認証テーブルを作成します(sql.php の使用が推奨されます)。 シェルアクセスができない場合は、PHPMyAdminのようなデータベース管理ツールを使用してcentral-auth.sqlをインポートすることもできます。

php maintenance/sql.php --wikidb centralauth extensions/CentralAuth/central-auth.sql

If AntiSpoof is installed, create the table via (Alternatively, you can copy an existing AntiSpoof table if you want to keep previous entries):

php maintenance/sql.php --wikidb centralauth extensions/CentralAuth/AntiSpoof/patch-antispoof-global.mysql.sql


$ php extensions/CentralAuth/maintenance/migratePass0.php
$ php extensions/CentralAuth/maintenance/migratePass1.php

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


警告 警告: A central login wiki 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 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 wfLoadExtension( 'CentralAuth' ); 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. 使用することが推奨されるサンプルクエリー : 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 wfLoadExtension line in LocalSettings.php, e.g.:

wfLoadExtension( 'CentralAuth' );
$wgCentralAuthDatabase = 'mycentralauthdatabase';

"SUL2" behavior

警告 警告: 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). これにより、XSSの脆弱性のリスクが軽減されます。
警告 警告: Universal sign-on may be broken in newer Google Chrome versions due to SameSite cookie policy. 解決方法 :
$wgCookieSameSite = "None";
$wgUseSameSiteLegacyCookies = true;

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; // Parameter deleted from MediaWiki 1.27
$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 (this parameter was deleted from MediaWiki 1.27).

Simulating SUL2 behavior on a single-instance development machine

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は、グローバル利用者名用の独自の'centralauth'データベースを使用します。

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.


最良の結果を得るために、memcachedの使用が推奨されます。 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 using CACHE_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 the objectcache table in its own database (with its own db prefix) when $wgMainCacheType is set to CACHE_NONE or CACHE_DB. これをCentralAuthで正常に動作させるために、中央のキャッシュテーブルを使用するようwikiを設定する必要があります。

If you want to make a central caching table in the centralauth database (and assuming one of your existing wikis has a database name of enwiki), run code like the following to copy the table to your other database:

CREATE TABLE centralauth.objectcache LIKE enwiki.objectcache

次に、以下の設定を全てのWikiに行い、中央のWikiが使用されるようにします :

$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


CentralAuth.php での構成設定
パラメーター 既定値 コメント
$wgCentralAuthDatabase 'centralauth' CentralAuthのデータを保存するデータベース名。

If this is not on the primary database connection, don't forget to also set up $wgDBservers to have an entry with a groupLoads setting for the 'CentralAuth' group. Alternatively you can use $wgLBFactoryConf to set up an LBFactoryMulti object.

To use a database with a table prefix, set this variable to "{$database}-{$prefix}".

$wgCentralAuthAutoMigrate false If true, existing unattached accounts will be automatically migrated if possible at first login.


If false, unattached accounts will not be harassed unless the individual account has opted in to migration.

$wgCentralAuthAutoMigrateNonGlobalAccounts false If true, 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).


$wgCentralAuthStrict false If true, remaining accounts which have not been attached will be forbidden from logging in until they are resolved.
$wgCentralAuthDryRun false If true, merging won't actually be possible through the Special:MergeAccount interface.
$wgCentralAuthCookies false If true, 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.

これには $wgCentralAuthCookies が必要です。

$wgCentralAuthCookieDomain '' Domain to set global cookies for.

For instance, '.wikipedia.org' to work on all wikipedia.org subdomains instead of just the current one. Leave blank to set the cookie for the current domain only, such as if all your wikis are hosted on the same subdomain.

$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 Special:CentralAutoLogin/start on each wiki.

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 by Special: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 $user->getOption( $pref ) !== User::getDefaultOption( $pref ), use the hook CentralAuthIsUIReloadRecommended.

$wgCentralAuthCookiesP3P true Specify a P3P header value to be used when setting CentralAuth cookies on the login wiki ($wgCentralAuthLoginWiki).

When set true, an invalid policy (lacking all required tokens) will be sent that none the less serves to allow current versions of IE with the default privacy settings to see the cookies in the auto-login check.

Set false to disable sending the P3P header altogether. Note this will likely break the auto-login check in IE, unless the header is being set globally elsewhere (e.g. in the webserver).

Otherwise, whatever string is assigned here will be sent as the value of the P3P header.

@var bool|string

$wgCentralAuthCreateOnView false If true, local accounts will be created for active global sessions on any page view. This is kind of creepy, so we're gonna have it off for a little bit.

With other default options, the local auto creation will be held off until an active login attempt, while global sessions will still automatically log in those who already have a merged account.

$wgCentralAuthRC [] Array of settings for sending the CentralAuth events to the RC Feeds.

@example $wgRCFeeds['example'] = array( 'uri' => "udp://localhost:1336", );

$wgCentralAuthLockedCanEdit [] List of local pages global users may edit while being globally locked.
$wgDisableUnmergedEditing false Disable editing for non-global accounts (except on NS_USER_TALK and NS_PROJECT_TALK).
$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.

@var bool

$wgCentralAuthUseEventLogging false Use the EventLogging extension to measure various activities.
$wgCentralAuthPreventUnattached false Don't allow new unattached accounts to be created.

@var bool

$wgCentralAuthEnableUserMerge false Whether to enable the global user merge tool.

This only controls the availability of the special page, and does not prevent LocalUserMergeJobs from running on the given wiki.

@var bool

$wgCentralAuthEnableGlobalRenameRequest false Feature flag for Special:GlobalRenameRequest.

@var bool

$wgCentralAuthCheckSULMigration false Enable special logic to attempt to ease the user facing impact of forced user migrations.

@var bool

$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.

@var array

$wgCentralAuthUseSlaves false Try to use slave DBs for reads instead of the master all the time.

@var bool

$wgOverrideCentralIdLookupProvider true Set false if you really want to use 'local' rather than 'CentralAuth' for $wgCentralIdLookupProvider. This isn't the default because using CentralAuth is almost always what you want if CentralAuth is installed.

@var bool

$wgGlobalRenameBlacklist 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:

  • Using a wiki-page: use a Title object to have a wiki-page (MediaWiki:GlobalRenameBlacklist for example) as the banned-list. The wiki-page must be a list with one item per line, and must exist otherwise Special:GlobalRenameRequest will throw a MWException.
    Example: $wgGlobalRenameBlacklist = Title::makeTitle( NS_MEDIAWIKI, 'GlobalRenameBlacklist' );.
  • Using a URL: put a complete URL which must return, using HTTP, a plain-text list of the banned users (and nothing else).
    For example, with a URL pointing to a wiki page: $wgGlobalRenameBlacklist = "https://yourwiki/yourpath/index.php?title=MediaWiki:GlobalRenameBlacklist&action=raw";

You can use the exact names or regular expressions, see $wgGlobalRenameBlacklistRegex.

@var Title|string|null

$wgGlobalRenameBlacklistRegex false Whether the list in $wgGlobalRenameBlacklist is using regular expressions. If set to false, users will be matched literally, if set to true the username will be tested against the regular expressions (provided that they are valid).

@var bool

$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 in BlockList a block against John made by Admins>Joe.

@var string


Old configuration settings in CentralAuth.php
パラメーター 有効期間 既定値 コメント
$wgCentralAuthAutoNew MediaWiki 1.12–1.26 (2a9795732276b0) false If true, new account registrations will be registered globally if the username hasn't been used elsewhere.


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:

利用者権限 技能 既定のグループ 状態
centralauth-admin Read-only access to global account status Not applicable Inactive; defunct
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-oversight 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-usermerge Globally merge multiple users Not applicable Requires UserMerge extension
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


Single-user login (SUL)

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. Users with the centralauth-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.


Screenshot of Special:CentralAuth interface on Meta-Wiki, 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. A hidden global account's username is not visible in any logs except the global account log.


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).


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.


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.


Extension:CentralAuth/API を参照