Chinaunix首页 | 论坛 | 认证专区 | 博客 登录 | 注册
  • 博客访问: 900329
  • 博文数量: 151
  • 博客积分: 340
  • 博客等级: 一等列兵
  • 技术积分: 2956
  • 用 户 组: 普通用户
  • 注册时间: 2009-04-01 11:50
个人简介

说点什么呢

文章分类

全部博文(151)

文章存档

2017年(1)

2015年(3)

2014年(30)

2013年(110)

2011年(6)

2009年(1)

微信关注

IT168企业级官微



微信号:IT168qiye



系统架构师大会



微信号:SACC2013

订阅
热词专题
友情链接
如何设置MediaWiki用户权限 2015-04-10 16:16:32

分类: LINUX

原文地址:如何设置MediaWiki用户权限 作者:renxiaobin32132

安装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;
// 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。
如此设定后,用户连首页和登录页面也看不到了。

阅读(1571) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~
评论热议
请登录后评论。

登录 注册