Extension:Lockdown(封锁)
MediaWiki的设计目标并不包含提供按页面的访问限制及部分的页面访问限制等功能。 如果您需要这种程度的权限控制,强烈建议您使用其他自带相关功能的内容管理系统。
声称可以提供访问控制功能的补丁或第三方扩展程序,和MediaWiki本体一同使用时,可能存在或反而导致安全漏洞,从而导致机密数据的泄露。 如需使用,请自行承担风险。 MediaWiki的开发人员和维基媒体基金会均不对任何潜在的数据泄露负任何责任。 此提醒会添加到所有此类扩展程序的页面开头,并不反映其实际安全状态。 关于更多信息,请见Security issues with authorization extensions。 |
发行状态: 稳定版 |
|
|---|---|
| 实现 | 用户权限 |
| 描述 | 实现按命名空间的用户组权限 |
| 作者 | Daniel Kinzler (Duesentrieb留言) |
| MediaWiki | 1.31+ |
| PHP | 5.5+ |
|
|
| 许可证 | GNU General Public License 2.0 or later |
| 下載 | README |
| 前往translatewiki.net翻譯Lockdown扩展 | |
| 問題 | 开启的任务 · 报告错误 |
Lockdown擴展實現一個可設定用戶組訪向指定命名空間及特殊頁面的方式。 这提供了相较默认的$wgGroupPermissions和$wgNamespaceProtection设置而言更細緻的权限控制模型。
以下有关MediaWiki默认使用的权限控制模型的页面可能有助于理解以下说明:
安装
- 下载文件,并解压
Lockdown文件夹到extensions/目录中。
开发者和代码贡献人员应改从Git安装此扩展,输入:cd extensions/ git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/Lockdown
- 請新增下列代码到您的LocalSettings.php文件的底部:
wfLoadExtension( 'Lockdown' );
- 按需求配置
完成 – 請导航至您的wiki上的Special:Version,以验证此扩展已成功安装。
示例
要使用Lockdown来:
- 防止用户在未登录的情况下使用Special:Export
- 將專案命名空間的編輯權限收窄到已登入的使用者(註冊使用者)
您可以这样做:
$wgSpecialPageLockdown['Export'] = [ 'user' ];
$wgNamespacePermissionLockdown[NS_PROJECT]['edit'] = [ 'user' ];
参见下文解释和更多示例。
配置
请注意Lockdown扩展只能用于收紧权限,不能用于赋予权限。 如果MediaWiki内置设置阻止了部分操作,Lockdown扩展并不能使之取消。
$wgSpecialPageLockdown
$wgSpecialPageLockdown可以指定每个特殊页面所对应的能够使用其的用户组。
比如,要将Special:Export限制为只有已登录用户可以使用,在LocalSettings.php中编写:
$wgSpecialPageLockdown['Export'] = [ 'user' ];
注意部分特殊页面本身就要求特定的权限。
比如说,Special:MovePage,其可以用于移动页面,就需要“move”权限(默认仅已登录用户拥有)。
此类限制无法使用Lockdown扩展覆盖。
一些特殊页面的实际标题并不像在wiki上显示的那样大写。 比如说。Recentchanges在软件内部是Special:RecentChanges,所以要限制此页面需要编写:
$wgSpecialPageLockdown['Recentchanges'] = [ 'user' ];
特殊页面标题的完整列表参见“MessagesEn.php”文件(的$specialPageAliases数组),或者也可以使用“siteinfo”这一API模块,例如在您的站点上可以通过/api.php?action=query&meta=siteinfo&siprop=specialpagealiases使用。
$wgActionLockdown
$wgActionLockdown可以指定每种操作所对应的能够使用其的用户组。
比如,要将历史记录页面限制为只有已登录用户可以使用,在LocalSettings.php中编写:
$wgActionLockdown['history'] = [ 'user' ];
Note that some actions can not be locked down this way.
In particular, it will not work for the ajax action.
$wgNamespacePermissionLockdown
$wgNamespacePermissionLockdown lets you restrict which user groups have which permissions on which namespace.
For example, to grant only members of the sysop group write access to the project namespace, use this:
$wgNamespacePermissionLockdown[NS_PROJECT]['edit'] = [ 'sysop' ];
Wildcards for either the namespace or the permission (but not both at once) are supported. More specific definitions take precedence:
$wgNamespacePermissionLockdown[NS_PROJECT]['*'] = [ 'sysop' ];
$wgNamespacePermissionLockdown[NS_PROJECT]['read'] = [ '*' ];
$wgNamespacePermissionLockdown['*']['move'] = [ 'autoconfirmed' ];
The first two lines restrict all permissions in the project namespace to members of the sysop group, but still allow reading to anyone. The third line limits page moves in all namespaces to members of the autoconfirmed group.
Note that this way, you cannot grant permissions that have not been allowed by the build-in $wgGroupPermissions setting. The following does not allow regular users to patrol edits in the main namespace:
$wgNamespacePermissionLockdown[NS_MAIN]['patrol'] = [ 'user' ];
Instead, you would have to grant this right in $wgGroupPermissions first, and then restrict it again using $wgNamespacePermissionLockdown:
$wgGroupPermissions['user']['patrol'] = true;
$wgNamespacePermissionLockdown['*']['patrol'] = [ 'sysop' ];
$wgNamespacePermissionLockdown[NS_MAIN]['patrol'] = [ 'user' ];
Note that when restricting read-access to a namespace, the restriction can easily be circumvented if the user has read access to any other namespace: by including a read-protected page as a template, it can be made visible. To avoid this, you would have to forbid the use of pages from that namespace as templates, by adding the namespace's ID to $wgNonincludableNamespaces:
$wgNamespacePermissionLockdown[NS_PROJECT]['read'] = [ 'user' ];
$wgNonincludableNamespaces[] = NS_PROJECT;
A user who has both read and move permissions for a page can move it to a namespace readable by them but not by others. This can effectively hide the page from other users. Note that move permission alone is not sufficient — users must also be able to view the source page in order to move it.
You can of course also use Lockdown with custom namespaces defined using $wgExtraNamespaces:
// define custom namespaces
$wgExtraNamespaces[100] = 'Private';
$wgExtraNamespaces[101] = 'Private_talk';
// restrict "read" permission to logged in users
$wgNamespacePermissionLockdown[100]['read'] = [ 'user' ];
$wgNamespacePermissionLockdown[101]['read'] = [ 'user' ];
// prevent inclusion of pages from that namespace
$wgNonincludableNamespaces[] = 100;
$wgNonincludableNamespaces[] = 101;
Note that custom namespaces should always be defined in pairs, the namespace proper (with an even id), and the associated talk namespace (with an odd id).
If you want to use constants to refer to your namespaces, you need to define them:
// define constants for your custom namespaces, for a more readable configuration
define('NS_PRIVATE', 100);
define('NS_PRIVATE_TALK', 101);
// define custom namespaces
$wgExtraNamespaces[NS_PRIVATE] = 'Private';
$wgExtraNamespaces[NS_PRIVATE_TALK] = 'Private_talk';
// restrict "read" permission to logged in users
$wgNamespacePermissionLockdown[NS_PRIVATE]['read'] = [ 'user' ];
$wgNamespacePermissionLockdown[NS_PRIVATE_TALK]['read'] = [ 'user' ];
// prevent inclusion of pages from that namespace
$wgNonincludableNamespaces[] = NS_PRIVATE;
$wgNonincludableNamespaces[] = NS_PRIVATE_TALK;
You could also use array_fill() to restrict multiple namespaces at once, e.g. if you wanted to restrict namespaces 0 to 2009 to editing by sysops only:
$wgNamespacePermissionLockdown = array_fill( 0, 2010, [ 'edit' => [ 'sysop' ] ] );
$wgNamespacePermissionLockdown與$wgActionLockdown的對比
在請求處理過程中,$wgActionLockdown 的檢查時間比 $wgNamespacePermissionLockdown 早得多(分別在 MediaWikiPerformAction 鉤點與 getUserPermissionsErrors 鉤點中進行檢查)。
若嘗試執行某項 $wgActionLockdown 不允許的操作,系統將顯示權限錯誤。
同樣地,$wgNamespacePermissionLockdown 可讓終端使用者知道哪些群組被允許執行該動作。
管理用户组
您可以透過頁面 Special:Userrights 來控制哪位使用者屬於哪些群組。 系統僅會建議現有的群組,但您可以透過在 $wgGroupPermissions 中為其建立一筆記錄來「建立」新群組(即使您實際上無需在此處設定權限,但該群組必須出現在陣列的左側)。 例如:
$wgGroupPermissions['somegroupname']['read'] = true;
如需更多資訊,請參閱說明:使用者權限、手冊:使用者權限與管理。
附加措施
圖片及其他上傳的檔案仍可被查看,並可嵌入至任何頁面中。 對「Image」命名空間的保護措施並不會阻止這種情況發生。 有關如何防止他人未經授權存取圖片的資訊,請參閱Image authorization。 另见:
另見
- GroupManager (BlueSpice) – 用於新增、編輯、及刪除使用者群組
- PermissionManager (BlueSpice) – 用於管理使用者群組的使用者權限
- UserProtect – 可針對每位使用者、每項權限及每個頁面進行保護
- PageOwnership – 多層級權限管理工具,適用於整個維基或特定頁面,並具備友善的介面
- AccessControl – 可限制對特定頁面和檔案的存取權限
- CategoryLockdown – 可依據類別和群組限制存取權限
- DisableSpecialPages – 可將特定頁面設為不可用
- CrawlerProtection – 阻擋匿名使用者執行操作,並限制其存取最常被 AI 爬蟲機器人濫用的特殊頁面
- complete list in: Category:User rights extensions zh
| 此扩展在以下wiki农场/托管网站和/或软件包中提供: |
- Page specific read access extensions/zh
- Stable extensions/zh
- User rights extensions/zh
- MediaWikiPerformAction extensions/zh
- SearchGetNearMatchComplete extensions/zh
- SearchableNamespaces extensions/zh
- GetUserPermissionsErrors extensions/zh
- GPL licensed extensions/zh
- Extensions in Wikimedia version control/zh
- All extensions/zh
- Pages using deprecated NoteTA template
- Extensions included in Canasta/zh
- Extensions included in MyWikis/zh
- Extensions included in Open CSP/zh
- Extensions included in ProWiki/zh
- View page extensions/zh
- Edit extensions/zh
