MediaWiki用户权限

来自站长百科
(重定向自MediaWiki权限修改
跳转至: 导航、​ 搜索

MediaWiki | 安装升级 | 功能使用 | 配置 | 插件使用 | FAQ

安装MediaWiki之后,用户的权限设置是完全开放的,需要做一些设置,对匿名用户的设置可以从修改LocalSettings.php入手,下载该文件,然后按照希望设置的用户权限,在文件中插入对应的设置语句,存储后再上传回去就可以了。

通过下面介绍的设置方法,可以阻止匿名用户注册,又或者阻止他们编辑,要求注册后才能够编辑,还可以设定注册前匿名用户可以查看那些页面。而在设置新用户的注册之后,管理人员仍可通过特殊页面手动为其他人创建用户。而用户的权限,则可以通过特殊页面内的User rights management进行管理。

LocalSettings.php用户权选设置相关选项

基本语法[ ]

$wgGroupPermissions['group']['right'] = true /* 或者 false */;

group代表用户组,right 是权限。如果是true ,就说明该用户组拥有该项权限,如果是false,就说明该用户组没有该项权限。

如果一个用户属于多个用户组,那么该用户拥有这些用户组中最高的权限。所有用户(包括未注册用户)包含在*用户组中,所有注册的用户包含在user用户组中。如果需要设置匿名用户不能编辑但是注册用户可以编辑,可以采取这样的方法,首先禁止所有用户编辑:

$wgGroupPermissions['*']['edit'] = false;

然后允许注册用户编辑:

$wgGroupPermissions['user']['edit'] = true;

  • 包含了所有用户,不仅仅是匿名用户(未注册用户),所以如果设置*的某一项权限是false,那么又要允许注册用户拥有该项权限就必须设置user的权限是true。

MediaWiki的默认设置[ ]

$wgGroupPermissions = array();
 
// Implicit group for all visitors
$wgGroupPermissions['*']['createaccount']    = true;
$wgGroupPermissions['*']['read']             = true;
$wgGroupPermissions['*']['edit']             = true;
$wgGroupPermissions['*']['createpage']       = true;
$wgGroupPermissions['*']['createtalk']       = true;
$wgGroupPermissions['*']['writeapi']         = true;
//$wgGroupPermissions['*']['patrolmarks']      = false; // let anons see what was patrolled
 
// Implicit group for all logged-in accounts
$wgGroupPermissions['user']['move']             = true;
$wgGroupPermissions['user']['move-subpages']    = true;
$wgGroupPermissions['user']['move-rootuserpages'] = true; // can move root userpages
//$wgGroupPermissions['user']['movefile']         = true;	// Disabled for now due to possible bugs and security concerns
$wgGroupPermissions['user']['read']             = true;
$wgGroupPermissions['user']['edit']             = true;
$wgGroupPermissions['user']['createpage']       = true;
$wgGroupPermissions['user']['createtalk']       = true;
$wgGroupPermissions['user']['writeapi']         = true;
$wgGroupPermissions['user']['upload']           = true;
$wgGroupPermissions['user']['reupload']         = true;
$wgGroupPermissions['user']['reupload-shared']  = true;
$wgGroupPermissions['user']['minoredit']        = true;
$wgGroupPermissions['user']['purge']            = true; // can use ?action=purge without clicking "ok"
$wgGroupPermissions['user']['sendemail']        = true;
 
// Implicit group for accounts that pass $wgAutoConfirmAge
$wgGroupPermissions['autoconfirmed']['autoconfirmed'] = true;
 
// Users with bot privilege can have their edits hidden
// from various log pages by default
$wgGroupPermissions['bot']['bot']              = true;
$wgGroupPermissions['bot']['autoconfirmed']    = true;
$wgGroupPermissions['bot']['nominornewtalk']   = true;
$wgGroupPermissions['bot']['autopatrol']       = true;
$wgGroupPermissions['bot']['suppressredirect'] = true;
$wgGroupPermissions['bot']['apihighlimits']    = true;
$wgGroupPermissions['bot']['writeapi']         = true;
#$wgGroupPermissions['bot']['editprotected']    = true; // can edit all protected pages without cascade protection enabled

// Most extra permission abilities go to this group
$wgGroupPermissions['sysop']['block']            = true;
$wgGroupPermissions['sysop']['createaccount']    = true;
$wgGroupPermissions['sysop']['delete']           = true;
$wgGroupPermissions['sysop']['bigdelete']        = true; // can be separately configured for pages with > $wgDeleteRevisionsLimit revs
$wgGroupPermissions['sysop']['deletedhistory']   = true; // can view deleted history entries, but not see or restore the text
$wgGroupPermissions['sysop']['deletedtext']      = true; // can view deleted revision text
$wgGroupPermissions['sysop']['undelete']         = true;
$wgGroupPermissions['sysop']['editinterface']    = true;
$wgGroupPermissions['sysop']['editusercss']      = true;
$wgGroupPermissions['sysop']['edituserjs']       = true;
$wgGroupPermissions['sysop']['import']           = true;
$wgGroupPermissions['sysop']['importupload']     = true;
$wgGroupPermissions['sysop']['move']             = true;
$wgGroupPermissions['sysop']['move-subpages']    = true;
$wgGroupPermissions['sysop']['move-rootuserpages'] = true;
$wgGroupPermissions['sysop']['patrol']           = true;
$wgGroupPermissions['sysop']['autopatrol']       = true;
$wgGroupPermissions['sysop']['protect']          = true;
$wgGroupPermissions['sysop']['proxyunbannable']  = true;
$wgGroupPermissions['sysop']['rollback']         = true;
$wgGroupPermissions['sysop']['trackback']        = true;
$wgGroupPermissions['sysop']['upload']           = true;
$wgGroupPermissions['sysop']['reupload']         = true;
$wgGroupPermissions['sysop']['reupload-shared']  = true;
$wgGroupPermissions['sysop']['unwatchedpages']   = true;
$wgGroupPermissions['sysop']['autoconfirmed']    = true;
$wgGroupPermissions['sysop']['upload_by_url']    = true;
$wgGroupPermissions['sysop']['ipblock-exempt']   = true;
$wgGroupPermissions['sysop']['blockemail']       = true;
$wgGroupPermissions['sysop']['markbotedits']     = true;
$wgGroupPermissions['sysop']['apihighlimits']    = true;
$wgGroupPermissions['sysop']['browsearchive']    = true;
$wgGroupPermissions['sysop']['noratelimit']      = true;
$wgGroupPermissions['sysop']['versiondetail']    = true;
$wgGroupPermissions['sysop']['movefile']         = true;
#$wgGroupPermissions['sysop']['mergehistory']     = true;

// Permission to change users' group assignments
$wgGroupPermissions['bureaucrat']['userrights']  = true;
$wgGroupPermissions['bureaucrat']['noratelimit'] = true;
// Permission to change users' groups assignments across wikis
#$wgGroupPermissions['bureaucrat']['userrights-interwiki'] = true;
// Permission to export pages including linked pages regardless of $wgExportMaxLinkDepth
#$wgGroupPermissions['bureaucrat']['override-export-depth'] = true;

#$wgGroupPermissions['sysop']['deleterevision']  = true;
// To hide usernames from users and Sysops
#$wgGroupPermissions['suppress']['hideuser'] = true;
// To hide revisions/log items from users and Sysops
#$wgGroupPermissions['suppress']['suppressrevision'] = true;
// For private suppression log access
#$wgGroupPermissions['suppress']['suppressionlog'] = true;

/**
 * The developer group is deprecated, but can be activated if need be
 * to use the 'lockdb' and 'unlockdb' special pages. Those require
 * that a lock file be defined and creatable/removable by the web
 * server.
 */
# $wgGroupPermissions['developer']['siteadmin'] = true;


阻止新用户注册[ ]

  • $wgGroupPermissions['*' ]['createaccount'] = false;

注意:阻止新用户注册,此时管理员可以到特殊页面上的用户登录页面(Special:UserLogin)里,输入希望为其建立帐户的某人的用户名与电子邮件地址,然后点击通过eMail(by email)按钮递交,系统将创建帐号并将随机生成的密码发送到指定email里。

设定匿名用户可看的页面[ ]

$wgWhitelistRead = array (”Main Page”, “Special:Userlogin”, “Wikipedia:Help”);

匿名用户只能看到Main Page、登录页面以及帮助页面。

修改其他的例子:$wgWhitelistRead = array (”首页”, “Special:Userlogin”, “某某Wiki:Help”);

设置匿名用户权限[ ]

  • $wgGroupPermissions['*' ]['createaccount'] = false;
  • $wgGroupPermissions['*' ]['read'] = true;
  • $wgGroupPermissions['*' ]['edit'] = false;
  • $wgGroupPermissions['user' ]['createaccount'] = true;
  • $wgGroupPermissions['user' ]['edit'] = true;


设置匿名用户可读内容[ ]

  • $wgWhitelistRead = array( "Main Page", "Special:Userlogin" );
  • $wgGroupPermissions['*' ]['read'] = false;

注意:具体需要对应自己的站点链接,而对于多字节语言的MediaWiki,例如中文首页链接index.php?title=%E9%A6%96%E9%A1%B5,这首页中文字符PHP可能无法正确解码。需要利用urldecode()函数转换一下,写为:

  • $wgWhitelistRead = array( urldecode("%E9%A6%96%E9%A1%B5") ;

禁止匿名用户编辑[ ]

  • #$wgGroupPermissions = array();
  • $wgGroupPermissions['*createaccount'] = false;
  • $wgGroupPermissions['*']['read'] = true;
  • $wgGroupPermissions['*']['edit'] = false;

“编辑”标签仍会显示,但匿名用户点击时会被提示要求进行登录。

等式右侧的值决定各组成员的权限。左侧第一方括号内的’*'代表包括匿名用户在内的所有成员。登录用户控制存放在’user’组,这些将综合决定user_groups数据表中的成员权限。

这些设置取代了以前的wgWhitelistAccount和wgWhitelistEdit。

如此设定后,用户连首页和登录页面也看不到了。

MediaWiki使用手册导航

安装升级

安装 | 升级

功能使用

MediaWiki语法 | MediaWiki后台 | MediaWiki上传图片

配置

MediaWiki界面设置 | MediaWiki基础设置 | MediaWiki上传图片 | MediaWiki导航栏设置 | MediaWiki权限修改 | MediaWiki的Logo修改 | MediaWiki用户权限MediaWiki的页面缓冲机制MediaWiki繁简共存版本的界面修改MediaWiki修改wiki式网址MediaWiki新开窗口打开外链MediaWiki Rewrite设置 | MediaWiki自定义皮肤 | MediaWiki流量统计 | MediaWiki数据库存储 | Mediawiki数据备份 | MediaWiki增加Google AdSense | MediaWiki默认时区修改 | 隐藏MediaWiki首页标题 | MediaWiki设置站点版权 | MediaWiki页脚 | MediaWiki名字空间 | MediaWiki重置密码 | MediaWiki页面分类 | URL重写 | 名字空间 | 添加广告 | 添加统计代码 | 左侧导航栏设置 | 页脚设置

插件使用

如何引用插件 | 常用插件

FAQ