author Colas Nahaboo <>
Sat, 26 Jan 2008 15:50:53 +0100
changeset 0 414e01d06fd5
child 1 e2915a7cbdfa
permissions -rw-r--r--
RELEASE 4.2.0 freetown
     1 %META:TOPICINFO{author="TWikiContributor" date="1183870141" format="1.1" version="35"}%
     3 ---+ TWiki Access Control
     5 _Restricting read and write access to topics and webs, by Users and groups_
     7 TWiki Access Control allows you restrict access to single topics and entire webs, by individual user and by user Groups. Access control, combined with TWikiUserAuthentication, lets you easily create and manage an extremely flexible, fine-grained privilege system.
     9 __%T% Tip:__ TWiki:TWiki.TWikiAccessControlSupplement on has additional documentation on access control.
    11 %TOC%
    13 #ImportantConsideration
    14 ---++ An Important Control Consideration
    16 Open, freeform editing is the essence of WikiCulture - what makes TWiki different and often more effective than other collaboration tools. For that reason, it is strongly recommended that decisions to restrict read or write access to a web or a topic are made with great care - the more restrictions, the less Wiki in the mix. Experience shows that _unrestricted write access_ works very well because:
    17    * *Peer influence* is enough to ensure that only relevant content is posted.
    18    * *Peer editing* - the ability for anyone to rearrange all content on a page - keeps topics focused.
    19    * In TWiki, content is transparently preserved under *revision control*:
    20       * Edits can be undone by the administrator (per default a member of %USERSWEB%.TWikiAdminGroup; see [[#ManagingGroups]]).
    21       * Users are encouraged to edit and refactor (condense a long topic), since there's a safety net.
    22 As a *collaboration guideline*:
    23    * Create broad-based Groups (for more and varied input), and...
    24    * Avoid creating view-only Users (if you can read it, you should be able to contribute to it).
    26 ---++ Permissions settings of the webs on this TWiki site
    27 %INCLUDE{SitePermissions}%
    29 __Note:__ Above table comes from SitePermissions
    31 ---++ Authentication vs. Access Control
    33 *Authentication:* Identifies who a user is based on a login procedure. See TWikiUserAuthentication.
    35 *Access control:* Restrict access to content based on users and groups once a user is identified.
    37 ---++ Users and Groups
    39 Access control is based on the familiar concept of Users and Groups. Users are defined by their WikiNames. They can then be organized in unlimited combinations by inclusion in one or more user Groups. For convenience, Groups can also be included in other Groups. 
    41 ---+++ Managing Users
    43 A user can create an account in TWikiRegistration. The following actions are performed:
    44    * WikiName and encrypted password are recorded using the password manager if authentication is enabled.
    45    * A confirmation e-mail is sent to the user.
    46    * A user home page with the WikiName of the user is created in the %USERSWEB% web.
    47    * The user is added to the %USERSWEB%.%WIKIUSERSTOPIC% topic.
    49 The default visitor name is %USERSWEB%.TWikiGuest. This is the non-authenticated user.
    51 #ManagingGroups
    52 ---+++ Managing Groups
    54 The following describes the standard TWiki support for groups. Your local TWiki may have an alternate group mapping manager installed. Check with your TWiki administrator if you are in doubt.
    56 Groups are defined by group topics located in the ==%USERSWEB%== web. To create a new group, visit  %USERSWEB%.TWikiGroups and enter the name of the new group ending in ==Group== into the "new group" form field. This will create a new group topic with two important settings:
    57    * ==Set <nop>GROUP = &lt; list of Users and/or Groups &gt;==
    58    * ==Set <nop>ALLOWTOPICCHANGE = &lt; list of Users and/or Groups &gt;==
    60 The GROUP setting is a comma-separated list of users and/or other groups. Example:
    61    * ==Set GROUP = %USERSWEB%.<nop>SomeUser, %USERSWEB%.<nop>OtherUser, %USERSWEB%.<nop>SomeGroup==
    63 The ALLOWTOPICCHANGE setting defines who is allowed to change the group topic; it is a comma delimited list of users and groups. You typically want to restrict that to the members of the group itself, so it should contain the name of the topic. This prevents users not in the group from editing the topic to give themselves or others access. For example, for the <nop>KasabianGroup topic write:
    64    * ==Set <nop>ALLOWTOPICCHANGE = %USERSWEB%.<nop>KasabianGroup==
    66 __%X% Note:__ TWiki has strict formatting rules. Make sure you have three spaces, an asterisk, and an extra space in front of any access control rule.
    68 #SuperAdminGroup
    69 ---+++ The Super Admin Group
    71 A number of TWiki functions (for example, renaming webs) are only available to administrators. Administrators are simply users who belong to the *SuperAdminGroup*. This is a standard user group, the name of which is defined by {SuperAdminGroup} setting in [[%SCRIPTURLPATH{"configure"}%][configure]]. The default name of this group is the =TWikiAdminGroup=. The system administrator may have chosen a different name for this group if your local TWiki uses an alternate group mapping manager but for simplicity we will use the default name !TWikiAdminGroup in the rest of this topic.
    73 You can create new administrators simply by adding them to the %USERSWEB%.TWikiAdminGroup topic. For example,
    74    * ==Set <nop>GROUP = <nop>%USERSWEB%.ElizabethWindsor, <nop>%USERSWEB%.TonyBlair==
    75 A member of the Super Admin Group has unrestricted access throughout the TWiki, so only trusted staff should be added to this group.
    77 ---++ Restricting Access
    79 You can define who is allowed to read or write to a web or a topic. Note that some plugins may not respect access permissions.
    81    * Restricting VIEW blocks viewing and searching of content. When you restric VIEW to a topic or web, this also restricts [[VarINCLUDE][INCLUDE]] and [[FormattedSearch][Formatted SEARCH]] from showing the content of the topics.
    82    * Restricting CHANGE blocks creating new topics, changing topics or attaching files.
    83    * Restricting RENAME prevents renaming of topics within a web.
    85 Note that there is an important distinction between CHANGE access and RENAME access. A user can CHANGE a topic, but thanks to version control their changes cannot be lost (the history of the topic before the change is recorded). However if a topic or web is renamed, that history may be lost. Typically a site will only give RENAME access to administrators and content owners.
    87 ---+++ Controlling access to a Web
    89 You can define restrictions on who is allowed to view a <nop>%WIKITOOLNAME% web. You can restrict access to certain webs to selected Users and Groups, by:
    91    * *authenticating all webs and restricting selected webs:* Topic access in all webs is authenticated, and selected webs have restricted access.
    92    * *authenticating and restricting selected webs only:* Provide unrestricted viewing access to open webs, with authentication and restriction only on selected webs.
    94    * You can define these settings in the %WEBPREFSTOPIC% topic, preferable towards the end of the topic:
    95       * ==Set <nop>DENYWEBVIEW = &lt; comma-delimited list of Users and Groups &gt;==
    96       * ==Set <nop>ALLOWWEBVIEW = &lt; comma-delimited list of Users and Groups &gt;==
    97       * ==Set <nop>DENYWEBCHANGE = &lt; comma-delimited list of Users and Groups &gt;==
    98       * ==Set <nop>ALLOWWEBCHANGE = &lt; comma-delimited list of Users and Groups &gt;==
    99       * ==Set <nop>DENYWEBRENAME = &lt; comma-delimited list of Users and Groups &gt;==
   100       * ==Set <nop>ALLOWWEBRENAME = &lt; comma-delimited list of Users and Groups &gt;==
   102 If your site allows hierarchical webs, then access to sub-webs is determined from the access controls of the parent web, plus the access controls in the sub-web. So, if the parent web has ==ALLOWWEBVIEW== set, this will also apply to the subweb. Also note that you will need to ensure that the parent web's ==FINALPREFERENCES== does not include the access control settings listed above. Otherwise you will not be able override the parent web's access control settings in sub-webs.
   104 Creation and renaming of sub-webs is controlled by the WEBCHANGE setting on the parent web (or ROOTCHANGE for [[#RootWebs][root webs]]). Renaming is additionally restricted by the setting of WEBRENAME in the web itself.
   106 __Note:__  If you restrict access to the %USERSWEB%, make sure to add the =TWikiRegistrationAgent= so that users can register. Example:
   107       * ==Set <nop>ALLOWWEBCHANGE = !TWikiAdminGroup, !TWikiRegistrationAgent==
   109 __Note:__  For Web level access rights Setting any of these settings to an empty value has the same effect as not setting them at all. Please note that the documentation of TWiki 4.0 and earlier versions of TWiki 4.1 did not reflect the actual implementation, e.g. an empty ALLOWWEBVIEW does _not_ prevent anyone from viewing the web, and an an empty DENYWEBVIEW does _not_ allow all to view the web.
   111 ---+++ Controlling access to a Topic
   113    * You can define these settings in any topic, preferable towards the end of the topic:
   114       * ==Set <nop>DENYTOPICVIEW = &lt; comma-delimited list of Users and Groups &gt;==
   115       * ==Set <nop>ALLOWTOPICVIEW = &lt; comma-delimited list of Users and Groups &gt;==
   116       * ==Set <nop>DENYTOPICCHANGE = &lt; comma-delimited list of Users and Groups &gt;==
   117       * ==Set <nop>ALLOWTOPICCHANGE = &lt; comma-delimited list of Users and Groups &gt;==
   118       * ==Set <nop>DENYTOPICRENAME = &lt; comma-delimited list of Users and Groups &gt;==
   119       * ==Set <nop>ALLOWTOPICRENAME = &lt; comma-delimited list of Users and Groups &gt;==
   121 Remember when opening up access to specific topics within a restricted web that other topics in the web - for example, the WebLeftBar - may also be accessed when viewing the topics. The message you get when you are denied access should tell you what topic you were not permitted to access.
   123 *Be careful* with empty values for any of these.
   125    * ==Set <nop>ALLOWTOPICVIEW = <nop>== <br />This means the same as not setting it at all. (This was documented wrong in versions 4.0.X, 4.1.0 and 4.1.1)
   127    * ==Set <nop>DENYTOPICVIEW = <nop>== <br />Since TWiki 4.0 this means _do not deny anyone the right to view this topic_. If DENYTOPICVIEW is set to an empty value anyone has access even if ALLOWTOPICVIEW or ALLOWWEBVIEW is defined. This allows to have very restrictive default access rights to an entire web and still allow individual topics to have more open access.
   129 The same rules apply to ALLOWTOPICCHANGE/DENYTOPICCHANGE and APPLYTOPICRENAME/DENYTOPICRENAME. Setting ALLOWTOPICCHANGE or ALLOWTOPICRENAME to en empty value means the same as not defining it. Setting DENYTOPICCHANGE or DENYTOPICRENAME to an empty value means that anyone can edit or rename the topic.
   131 %X% _The setting to an empty has caused confusion and great debate and it has been decided that the empty setting syntax will be replaced by something which is easier to understand in the 4.2 version of TWiki. A method to upgrade will be provided. Please read the release notes carefully when you upgrade._
   133 See "How TWiki evaluates ALLOW/DENY settings" below for more on how ALLOW and DENY interacts.
   135 ---+++ Controlling access to Attachments
   137 Attachments are referred to directly, and are not normally indirected via TWiki scripts. This means that the above instructions for access control will _not_ apply to attachments. It is possible that someone may inadvertently publicise a URL that they expected to be access-controlled.
   139 The easiest way to apply the same access control rules for attachments as apply to topics is to use the Apache =mod_rewrite= module, and configure your webserver to redirect accesses to attachments to the TWiki =viewfile= script. For example,
   141 <verbatim>
   142     ScriptAlias /twiki/bin/ /filesystem/path/to/twiki/bin/
   143     Alias /twiki/pub/       /filesystem/path/to/twiki/pub/
   145     RewriteEngine on
   146     RewriteCond %{REQUEST_URI} !^/+twiki/+pub/+TWiki/+.+
   147     RewriteRule ^/+twiki/+pub/+([^/]+)/+((([^/]+)/+)+)(.+) /twiki/bin/viewfile/$1/$4?filename=$5 [L,PT]
   148 </verbatim>
   150 That way all the controls that apply to the topic also apply to attachments to the topic. Other types of webserver have similar support.
   152 __Note:__ Images embedded in topics will load much slower since each image will be delivered by the =viewfile= script.
   154 #RootWebs
   155 ---+++ Controlling who can manage top-level webs
   157 Top level webs are a special case, because they don't have a parent web with a %WEBPREFSTOPIC%. So there has to be a special control just for the root level.
   158    * You can define these settings in the %USERSWEB%.%TWIKIPREFSTOPIC% topic, preferable towards the end of the topic:
   159       * ==Set <nop>DENYROOTCHANGE = &lt; comma-delimited list of Users and Groups &gt;==
   160       * ==Set <nop>ALLOWROOTCHANGE = &lt; comma-delimited list of Users and Groups &gt;==
   161 Note that you do *not* require =ROOTCHANGE= access to rename an existing top-level web. You just need =WEBCHANGE= in the web itself.
   163 ---+++ How TWiki evaluates ALLOW/DENY settings
   165 When deciding whether to grant access, TWiki evaluates the following rules in order (read from the top of the list; if the logic arrives at *PERMITTED* or *DENIED* that applies immediately and no more rules are applied). You need to read the rules bearing in mind that VIEW, CHANGE and RENAME access may be granted/denied separately.
   167    1 If the user is an [[#SuperAdminGroup][administrator]]
   168       * access is *PERMITTED*.
   169    1 If DENYTOPIC is set to a list of wikinames
   170       * people in the list will be *DENIED*.
   171    1 If DENYTOPIC is set to _empty_ ( i.e. <tt>Set DENYTOPIC =</tt> )
   172       * access is *PERMITTED* _i.e_ no-one is denied access to this topic.%BR%
   173         %X% __Attention:__ Use this with caution. This is __deprecated__ and will likely change in the next release.
   174    1 If ALLOWTOPIC is set
   175       1 people in the list are *PERMITTED*
   176       1 everyone else is *DENIED*
   177    1 If DENYWEB is set to a list of wikinames
   178       * people in the list are *DENIED* access
   179    1 If ALLOWWEB is set to a list of wikinames
   180       * people in the list will be *PERMITTED*
   181       * everyone else will be *DENIED*
   182    1 If you got this far, access is *PERMITTED*
   184 ---++ Access Control quick recipes
   186 ---+++ Obfuscating Webs
   188 Another way of hiding webs is to keep them hidden by not publishing the URL and by preventing the ==all webs== search option from accessing obfuscated webs. Do so by enabling the ==NOSEARCHALL== variable in %WEBPREFSTOPIC%:
   189    * ==Set <nop>NOSEARCHALL = on==
   191 This setup can be useful to hide a new web until content its ready for deployment, or to hide view access restricted webs.
   193 __%X% Note:__ Obfuscating a web without view access control is *very* insecure, as anyone who knows the URL can access the web.
   195 ---+++ Restrict Access to Whole TWiki Site
   197 For a firewalled TWiki, e.g. an intranet wiki or extranet wiki, you want to allow only invited people to access your TWiki. In this case, enable [[TWikiUserAuthentication#ApacheLogin][user authentication with ApacheLogin]] and lock down access to the whole =twiki/bin= and =twiki/pub= directories to all but valid users. In the Apache =.htaccess= file or the appropriate =.conf= file, replace the =&lt;FilesMatch "(attach|edit|...= section with this:
   199 <verbatim>
   200 <FilesMatch ".*">
   201        require valid-user
   202 </FilesMatch>
   203 </verbatim>
   205 If needed, you can further restrict access to selected webs with ALLOWWEBVIEW and other access control settings.
   207 __Note:__ With this configuration, someone with access to the site needs to register new users.
   209 ---+++ Authenticate all Webs and Restrict Selected Webs
   211 Use the following setup to authenticate users for topic viewing in all webs and to restrict access to selected webs. Requires TWikiUserAuthentication to be enabled.
   213    1. Set =require valid-user= on your =view= script in .htaccess or the appropriate Apache .conf file. As of 4.x, this looks like: =FilesMatch "(attach|edit|manage|rename|save|view|upload|mail|logon|.*auth).*"= (normally =view= is not in that list).
   214    1. *Restrict* view access to selected Users and Groups. Set one or both of these variables in its %WEBPREFSTOPIC% topic:
   215       * ==Set <nop>DENYWEBVIEW = &lt; list of Users and Groups &gt;==
   216       * ==Set <nop>ALLOWWEBVIEW = &lt; list of Users and Groups &gt;==
   217       * __Note:__ =DENYWEBVIEW= is evaluated before =ALLOWWEBVIEW=. Access is denied if the authenticated person is in the =DENYWEBVIEW= list, or not in the =ALLOWWEBVIEW= list. Access is granted if =DENYWEBVIEW= and =ALLOWWEBVIEW= are not defined.
   218    1. If you still want public users to be able to register automatically follow TWiki:TWiki.RegisterOnViewRestrictedSite.
   220 ---+++ Authenticate and Restrict Selected Webs Only
   222 Use the following setup to provide unrestricted viewing access to open webs, with authentication only on selected webs. Requires TWikiUserAuthentication to be enabled.
   224    1. *Restrict* view access to selected Users and Groups. Set one or both of these variables in its %WEBPREFSTOPIC% topic:
   225       * ==Set <nop>DENYWEBVIEW = &lt; list of Users and Groups &gt;==
   226       * ==Set <nop>ALLOWWEBVIEW = &lt; list of Users and Groups &gt;==
   227       * __Note:__ =DENYWEBVIEW= is evaluated before =ALLOWWEBVIEW=. Access is denied if the authenticated person is in the =DENYWEBVIEW= list, or not in the =ALLOWWEBVIEW= list. Access is granted if =DENYWEBVIEW= and =ALLOWWEBVIEW= are not defined.
   229 ---+++ Hide Control Settings
   231 __%T% Tip:__ To hide access control settings from normal browser viewing, you can put them into the topic-local settings. You can access those settings via the "More" screen, as explained in [[TWikiVariables#Setting_Preferences_Variables][TWikiVariables]].
   233 Alternatively, place them in HTML comment markers, but this exposes the access setting during ordinary editing.
   235 <blockquote>
   236 ==&lt;!--== <br />
   237 ==&nbsp;  * Set <nop>DENYTOPICCHANGE = %USERSWEB%.<nop>SomeGroup== <br />
   238 ==--&gt;==
   239 </blockquote>
   243 __Related Topics:__ AdminDocumentationCategory, TWikiUserAuthentication, TWiki:TWiki.TWikiAccessControlSupplement
   245 -- __Contributors:__ TWiki:Main.PeterThoeny, TWiki:Main.MikeMannix, TWiki:Main.CrawfordCurrie