This page is a translated version of the page Extension:AccessControl and the translation is 18% complete.
MediaWiki 拡張機能マニュアル
OOjs UI icon advanced-invert.svg
リリースの状態: 安定
実装 利用者権限 , パーサー拡張機能 , タグ
説明 内部グループまたは利用者スペースのグループ リストに基づいて、特定のページへのアクセスを制限できるようにする
作者 Aleš Kapica (Wantトーク)
最新バージョン 4.1 (2021-05-13)
互換性の方針 master は後方互換性を維持しています。
MediaWiki 1.29+
PHP 7.2+
データベースの変更 はい
ライセンス GNU 一般公衆利用許諾書 2.0 以降
Support DCEwiki または Thewoodcraft.org
  • $wgAdminCanReadAll
  • $wgAccessControlRedirect
‎<accesscontrol> (not need anymore)
Quarterly downloads 31 (Ranked 149th)
translatewiki.net で翻訳を利用できる場合は、AccessControl 拡張機能の翻訳にご協力ください
問題点 未解決のタスク · バグを報告

The AccessControl extension allows restricting access to specific pages based on internal groups or group lists from user space.

MediaWikiは既定の状態ではコンテンツ管理システム (CMS) として設計されていませんが、企業や学校のイントラネットとして使用する場合、機密データを保護する必要があります。 AccessControl は、この目的のために開発されました。

この拡張機能がサイト セキュリティの要件をどのように満たしているか

  警告: 古いバージョンの MediaWiki はさまざまな方法でバイパスできるため、MediaWiki の最新の安定したバージョンを使用することをお勧めします!
Atom/RSS feeds, diff, & revision links
Page content is protected, but when opening a page from history a piece of raw content will appear. If the <accesscontrol> tag was placed at the beginning, a potential attacker may be able to see the names of contributing users!
Listings & search
Unless otherwise noted, if there is any page with protected content in search results, the user is redirected away. Since extension version 2.5, searching may be allowed too. But it should be borne in mind that the displayed search results can compromise sensitive data. Therefore, do not write in your wiki sensitive information, such as passwords, that could be obtained through a fulltext search if searching through the contents of pages protected through an access control is allowed!
Inclusion/transclusion, related rights, & other extensions
Pages containing the <accesscontrol> tag, or including another page protected by the <accesscontrol> tag, are secure. The <accesscontrol> tag is processed in raw wikitext before HTML conversion.
  警告: When using Extension:DynamicPageList (third-party) , you must know that this extension selects from content pages before the parser analyzes wikitext. Protection of generated pages by an <accesscontrol> tag depends on the tag being included in the content of new page.
The problem with redirection was repaired in version 1.1
API & action links
For each anonymous user the action class is automatically set to false, besides the view attribute for unprotected pages. Allowed actions for authorized users depend on the permissions settings of MediaWiki and the username listed in the access list pages use.
Edit Section & watching pages
Options are available only to registered users if they are logged in and are on the security access list.
  警告: The extension AccessControl does not protect files against direct access via URL! If files cannot be publicly available, they must be protected at the server level!
XML export (Special:Export)
Warning: AccessControl version < 2.0, was based on a hook unprotected from MediaWiki's side before exporting pages to raw code. Therefore, if you use AccessControl version < 2.0, you must prohibit the special page to prohibit exporting the pages from MediaWiki.
Author backdoor
Extension AccessControl does not have a backdoor!
I recommend turning off caching. See the previous paragraphs.

More info about potential problems regarding security is on the page Security issues with authorization extensions.


Since version 2.1 the extension examines the embedded page or template as well.
  • Easy to set up and simple to use.
  • No patches to MediaWiki core.
  • Unlimited groups.
  • Dual mode access control:
    • View control.
    • Edit control, including restrictions on manual edit access when using action=edit in the URL.
  • User groups may use any namespace.
    • Namespaces with group lists may be protected by another extension.
  • MediaWiki sysop group may view and edit the protected pages.
    • Controlled by extension variable $wgAdminCanReadAll
  • Access may be granted to multiple groups
  • Read-only access may be granted to both groups and individual users.
  • Unauthorized users can use the search feature only if is it allowed.

See how this extension meets the requirements for site security.


Manual (in Czech language for now) here as wiki page, but is prepared for translation. If you want to contribute to creating an English version, you must donate any amount of money to pay for a commercial translator, because the author does not have the time and skills for it. The man page (for now only Czech version) is part of the source code, and can be imported into your private MediaWiki instance if you want.


Git repository of the AccessControl has two branches released. Master branch is based on the old version, which support only old syntax of the accesslists. It's separated for backward compatibility with the old versions MediaWiki.

A new version of the extension 4.0 in the separate branch form-support was developed for using with the Extension:Page Forms – as accesslist you may use any template, but the old syntax of accesslists is supported. Changes for using with the VisualEditor was implemented too.

You may get code from git:

git clone -b form-support https://gerrit.wikimedia.org/r/p/mediawiki/extensions/AccessControl.git
  警告: Versions 3.x are obsolete, and an upgrade is recommended, because these versions don't check before saving the code if the template includes itself. MediaWiki allows it, but the result is a looped and inaccessible page. The only solution for this is to disable the AccessControl extension, remove the problematic code from the page, and then reenable.

Step 1: Local Settings File

  • Add the following lines to the bottom of your LocalSettings.php:
require_once "extensions/AccessControl/AccessControl.php";

#if this one can't run it you can try this

wfLoadExtension( 'AccessControl' );
  • Add a namespace to the LocalSettings.php file for the purpose of creating groups.

If you're not sure which namespace ID to use, then use 730 and 731 as detailed at the extension defalt namespaces listing. See step 2 for more information on how to do this.

  • Check the settings in AccessControl.php.

These can be set in LocalSettings.php:

$wgAdminCanReadAll = true;			// sysop users can read all restricted pages

$wgAccessControlRedirect = false;	// false disables AccessControl's redirection,
                                    // thus no longer controlling access based on
                                    // the "<accesscontrol>" tag.

Step 2: Create User Groups

  • This method has changes in the latest version, please see note 1 at the bottom of this page. (User lists must be stored in the main namespace).

User groups are simply standard wiki pages that are part of a namespace other than the default namespace. For ease of use, it is suggested that a specific custom namespace is created for the explicit purpose of managing access control list pages For your custom namespace, if you're not sure which namespace ID to use, then use 730 and 731 as detailed at the extension defalt namespaces listing. For your convenience, IDs 730-739 are reserved for your use for this extension.

// Define constants for my additional namespaces.
define("NS_ACCESSCONTROLGROUP", 730); // This MUST be even.
define("NS_ACCESSCONTROLGROUP_TALK", 731); // This MUST be the following odd integer.

// Add namespaces.
$wgExtraNamespaces[NS_ACCESSCONTROLGROUP] = "AccessControlGroup";
$wgExtraNamespaces[NS_ACCESSCONTROLGROUP_TALK] = "AccessControlGroup_talk"; // Note underscores in the namespace name.
  • Create a wiki page with a users list in any namespace[1]
    • It is not sufficient to simply create a page with a colon (:) in the name, this extension requires the use of a namespace and one or more pages within namespaces
    • Page Name Example: My:Group
      • The namespace is My
      • The group page is Group
        • This is the name of user group
        • Users are added to the group in a bulleted list
    • Page Content Example
      • Presume that the namespace IT exists
        • Note that in v3.0 you also need to register the namespace IT either in LocalSettings.php e.g. $wgAccessControlNamespaces = array(NS_IT); or modify the extension.json.

Furthermore IT: should not be specified in the accesscontrol tag, just "Department"

      • Create a page in the namespace titled "Department"
      • Create users "John Doe" and "Jane Doe" in the group. The group information is contained on the page "Department".
      • Each username appears as a list item.
* John Doe
* Jane Doe (ro)
User names listed with "(ro)" at the end can only read the protected article, not edit it. For other groups of users, you can create another member list with the name Department in another namespace. Note that the user's name must start with a capital letter!
To protect the IT namespace you can use the Lockdown extension, but you can also use the ‎<accesscontrol> tag to protect it.

Step 3: Additional Access Control

  • Depending on localization, your wiki needs pages created to which anonymous or unauthorized users will be redirected. You have to create them in advance because some of them can't access pages from another page.
  • The safety of the page is provided by the <accesscontrol> tag. If there isn't a tag or the page is empty, it's freely accessible to logged-in users that can read and edit the page. No user, logged in or anonymous, will have read-only access.
  • Members from groups listed in the <accesscontrol> tag can edit the page only if the group title isn't listed with "(ro)" and if they don't have read only access set in the group member list.
  • By default the variable $wgAdminCanReadAll is set to true so that members of sysop can edit user group pages in any namespace.
  警告: When set to false, members of sysop can't read and edit pages protected with the <accesscontrol> tag, which may lead to big trouble. This can only be remedied on the code level.
Example tag code
In v3.0 the namespace was automatically added, thus <accesscontrol>Department</accesscontrol> worked for me.

In this example, all users from the groups "Administrators", "IT:Department" and "Sales" can read the page but only the users from "Administrators" group (if exists) and John Doe from "IT:Department" user group can edit it.

Usage on Pages to Control Access

That is for the installation. To restrict access to a page for specific user groups, just include the names of the allowed user groups (separated by commas) as the content of the <accesscontrol> tag in the top of the content page.


MediaWiki バージョン:
1.21 – 1.28

Version 2.5.1 is strongly recommended to be used.

バージョン 2.3 未満

  • There was a problem in function fromTemplate() causing AccessControl to ignore tags from included pages or templates. Actualization is recommended!

バージョン 2.0 以降

MediaWiki バージョン:
1.18 – 1.20
  警告: From version 2.0 the extension does not use wiki user groups (except sysop), only groups created by user access lists!
  • Pages can have only one <accesscontrol> element.
  • If the user is a member of multiple groups, the group that gives them more access is assumed.
  • This extension uses a MediaWiki hook that is called whenever a search result is displayed.

This means that a page that has an ACL will trigger an "Access Denied" message for end users who happen to search for text contained in a protected page. A simple solution is to put pages that require AccessControl into another namespace and then disable searching for that namespace. Although this isn't really a bug, it is undesirable behavior. Click here for an example showing a work around.

  警告: MediaWiki >= 1.21 contains new a framework ContentHandler and extension version 2.1 is unusable. Use AccessControl version 2.2 which is updated for MediaWiki 1.21 and above.

バージョン 1.3 以下

MediaWiki バージョン:
  • Groups from MediaWiki must not be in localized form! sysop cannot be Správce, etc.
  • A page may have multiple <accesscontrol> elements, with access accepted from groups in any tag.
  • Anonymous users do not have access to pages protected by <accesscontrol> elements.
  • If variable $wgAdminCanReadAll is true, sysops always have edit access.

MediaWiki Version Testing

Version 4.1 from branch form-support of git repository (see link for clone on top of this page) was tested on MediaWiki 1.35 the current stable release of long-term support (September 2023)
  • バージョン 3.0.1 は MediaWiki 1.34.0 でテストされましたが、廃止されました。アップグレードをお勧めします。
  • バージョン 2.5.1 は MediaWiki 1.33.0-alpha (5eb97ec) でテストされました
  • バージョン 2.6 は MediaWiki 1.27.0-rc.0 (57f722a) でテストされました
  • バージョン 2.5 は MediaWiki 1.27.0 (git リポジトリから) でテストされました
  • Version 2.5 was tested on MediaWiki 1.22.9 (from git repository)
  • Version 2.3 was tested on MediaWiki 1.22.0 (from git repository)
  • Version 2.2 was tested on MediaWiki 1.22.0 (from git repository)
  • Version 2.0 was tested on MediaWiki 1.19-alpha (from svn repository)
  • Version 1.2 was tested on MediaWiki 1.15.5-1 (from Debian repository)
  • Version 1.1 was tested on MediaWiki 1.16.0(b3). Works fine, except that it needed a minor change to line 358 of AccessControl.php (remove '&' from parameter to function controlEditAccess() ). When viewing a page on a Linux server, the ‎<accesscontrol> tags show. But on a Windows server, the tags don't show and it is fine! Still haven't figured that one out, but it is ok for my application.
  • Version 1.1 was tested on MediaWiki 1.15
  • Version 1.0 of this extension has been tested and works fine on MediaWikis > 1.12.x.
  • Version 1.1 tested on MediaWiki 1.16.1 with new patch from http://git.felk.cvut.cz/pub/git?p=accesscontrol.git;a=commitdiff;h=2f678deed0e4e4f77620e391c94559c7b50102a9


The first version of this extension (1.x) was based on Group Based Access Control , but without bugs the original had.[2]



  1. As of version 2.0, it only works with ACLs stored in the main namespace. It also can only protect pages that are in the main namespace. Changes need to be made to $getUsersFromPages and $getContentPage to correct this behavior. Click here to see a patched version of the extension that is compatible with namespaces.
  2. Unlike Group Based Access Control , double commas aren't used to split the content of an ‎<accesscontrol> tag when more access lists are used. Only one comma is required. And is not necessary to use the ',,' separator at the end of the element content.