Розширення:CentralAuth
CentralAuth дозволяє розділяти глобальні облікові записи між проєктами. Це розширення додає наступні нові спеціальні сторінки: Special:CentralAuth, Special:CentralLogin (unlisted special page), Special:CentralAutoLogin (unlisted special page), Special:CreateLocalAccount, Special:MergeAccount, Special:GlobalGroupMembership, Special:GlobalGroupPermissions, Special:WikiSets, Special:GlobalUsers, Special:MultiLock, Special:GlobalRenameUser, Special:GlobalRenameProgress
Рекомендується завантажувати ту версію CentralAuth, що відповідає вашій версії MediaWiki.
Встановлення
Передумови використання CentralAuth див. у розділі встановлення нижче. Тоді слідуйте цими інструкціями, коли будете готові активувати CentralAuth:
- Завантажте останній зняток і розпакуйте його у свою директорію
extensions
. - Оберіть базу даних і створіть таблиці CentralAuth. Можна використати наявну базу даних або створити нову; розширення за замовчуванням використовує базу даних на ім'я
centralauth
(див. нижче$wgCentralAuthDatabase
). Використайте цю базу даних, потім виконайтеtables-generated.sql
.- Якщо ви використовуєте Extension:AntiSpoof , то вам потрібно створити глобальну таблицю
spoofuser
(для блокування нових імен користувачів, схожих на наявні в будь-якій вікі). Один зі способів зробити це — вивантажити таблицюspoofuser
з бази даних локальної вікі й імпортувати її у нову$wgCentralAuthDatabase
.
- Якщо ви використовуєте Extension:AntiSpoof , то вам потрібно створити глобальну таблицю
- Додайте
wfLoadExtension( 'CentralAuth' );
до LocalSettings.php для кожної своєї вікі, чи в інший файл PHP, який включено доLocalSettings.php
кожної з ваших вікі. - Тепер розширення повинно бути активним.
Тут приклад команд оболонки й SQL для створення бази даних centralauth, копіювання таблиці spoofuser і міграції наявних користувачів до неї. Замініть $wgDBname і $wgDBuser значеннями для інсталяції вашої власної вікі.
Створіть нову базу даних (пам'ятайте, що цей крок необов'язковий, можна натомість використати одну з наявних баз даних, у цьому випадку пропустіть до кроку створення таблиць):
$ 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';
quit
Наступне припускає, що ваша теперішня робоча директорія є інсталяцією вашого MediaWiki (а не директорією CentralAuth).
Створіть таблиці центральної авторизації (бажано з використанням sql.php
.
За відсутність доступу до оболонки, можна також імпортувати tables-generated.sql
через інструменти адміністрування бази даних, як-от PHPMyAdmin):
Версія MediaWiki: | ≥ 1.38 Gerrit change 758563 |
php maintenance/sql.php --wikidb centralauth extensions/CentralAuth/schema/<db_type>/tables-generated.sql
Версія MediaWiki: | ≤ 1.37 Gerrit change 758563 |
php maintenance/sql.php --wikidb centralauth extensions/CentralAuth/central-auth.sql
Якщо інстальований AntiSpoof, то створіть таблицю через (Альтернативно, можете скопіювати наявну таблицю AntiSpoof, якщо бажаєте зберегти попередні записи):
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
Наскрізний контроль — дружніше до користувача встановлення за вищенаведені інструкції.
Встановлення
Спершу, вам потрібно сконфігурувати свою вікі-родину, використовуючи $wgConf
, або CentralAuth не зможе використовуватися для вашої вікі-родини.
Це включає встановлення $wgLocalDatabases
і присвоєння її $wgConf->wikis
, та $wgConf->settings
(мінімально $wgCanonicalServer
, $wgServer
і $wgArticlePath
).
Обережно слідуйте прикладам.
Впевніться в розміщенні конфігураційного коду після рядка wfLoadExtension( 'CentralAuth' );
у LocalSettings.php
.
Якщо ви створюєте нову вікі-родину, то майте на увазі, що може бути легше, якщо бази даних для вікі в кожній групі матимуть той самий суфікс (наприклад, гіпотетичні бази даних enwiki
, dewiki
, frwiki
тощо, що належать одній і тій самій групі, всі мають суфікс «wiki
»).
Після інсталяції розширення, ви маєте зібрати деякі дані у базу даних CentralAuth. Задля ретроактивного встановлення глобальних облікових записів, ви матимете виконати сценарії migratePass0.php та migratePass1.php. Перший зберігає інформацію про ваші вікі у базі даних CentralAuth, а другий — використовує автоматичну евристику міграції для генерації глобальних облікових записів. Користувач може злити свої облікові записи вручну через Special:MergeAccount. Сухі запуски можуть бути використані з метою тестування.
Для увімкнення глобальних груп, ви матимете зробити запис у таблицю global_group_permissions
своєї бази даних CentralAuth, з ggp_group='steward'
та (для доступу до інтерфейсу керування групами) ggp_permission=globalgrouppermissions
.
Рекомендований до використання зразок запиту: INSERT INTO global_group_permissions (ggp_group,ggp_permission) VALUES ('steward','globalgrouppermissions'), ('steward','globalgroupmembership');
.
Тоді, виконайте migrateStewards.php
для підвищення статусу локальних стюардів до глобальних.
Є різні налаштування, які ви можете захотіти змінити (наприклад, чи забезпечувати єдиний вхід крізь увесь домен), перелічені на CentralAuth.php.
Зокрема, ви можете захотіти перевизначити значення $wgCentralAuthDatabase
за замовчування, що ваша база даних CentralAuth називається інакше, ніж 'centralauth'
.
Переконайтеся, що ви помістили такі налаштування після рядка wfLoadExtension
у LocalSettings.php
, наприклад:
wfLoadExtension( 'CentralAuth' );
$wgCentralAuthDatabase = 'mycentralauthdatabase';
Поведінка «SUL2»
This page is outdated. |
Please expand this page. |
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).
Симуляція поведінки SUL2 на одно-примірниковій машині розробки
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.
Проблеми кешування
For best results, it is recommended to use 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
.
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 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
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 = array( '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.
Конфігурація
параметр | за замовчуванням | коментар |
---|---|---|
$wgCentralAuthDatabase
|
'centralauth'
|
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 " |
$wgCentralAuthAutoMigrate
|
false
|
If true , existing unattached accounts will be automatically migrated if possible at first login.
Any new account creations will be required to attach. If |
$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).
This was formerly controlled by |
$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. This requires |
$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 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 |
$wgCentralAuthCookiesP3P
|
true
|
Specify a P3P header value to be used when setting CentralAuth cookies on the login wiki ($wgCentralAuthLoginWiki ).
When set 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 |
$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:
You can use the exact names or regular expressions, see @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 |
Старі параметри конфігурації
параметр | час життя | за замовчуванням | коментар |
---|---|---|---|
$wgCentralAuthAutoNew
|
MediaWiki 1.12–1.26 (2a97957–32276b0) | 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:
User right | Abilities | Default group | Status |
---|---|---|---|
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-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 |
Функції
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.
Блокування та приховання глобальних користувачів
A global account can be locked or hidden by a user with the centralauth-lock
and centralauth-suppress
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 [[git:mediawiki/extensions/CentralAuth/+/HEAD/{{{1}}}|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.
API
Див. Extension:CentralAuth/API .
Посилання
Див. також
- Специфікації єдиного входу на Мета-Вікі
- Help:Unified login on Meta-Wiki
$wgSharedDB
- Global session threat assessment
- w:Wikipedia:Integrated watchlists
- Потік керування CentralAuth
- wikitech:Stuck global renames
Це розширення використовується в одному або декількох проектах Вікімедіа. Це, мабуть, означає, що розширення стабільне і працює досить добре, щоб його могли використовувати веб-сайти з великим трафіком. Шукайте назву цього розширення у файлах конфігурації Wikimedia CommonSettings.php та InitialiseSettings.php, щоб побачити, де це встановлене. Повний перелік розширень, встановлених на певній вікі, можна переглянути на сторінці Special:Version вікі. |
This extension is included in the following packages and/or wiki farms: This is not an authoritative list. Some wiki farms/hosts may contain this extension even if they are not listed here. Always check with your wiki farms/hosts or bundle to confirm. |