buildrelease
[openafs-wiki.git] / TWiki / TWikiAccessControl.mdwn
1 <div>
2   <ul>
3     <li><a href="#TWiki Access Control"> TWiki Access Control</a><ul>
4         <li><a href="#An Important Control Considerati"> An Important Control Consideration</a></li>
5         <li><a href="#Permissions settings of the webs"> Permissions settings of the webs on this TWiki site</a></li>
6         <li><a href="#Authentication vs. Access Contro"> Authentication vs. Access Control</a></li>
7         <li><a href="#Users and Groups"> Users and Groups</a><ul>
8             <li><a href="#Managing Users"> Managing Users</a></li>
9             <li><a href="#Managing Groups"> Managing Groups</a></li>
10             <li><a href="#The Super Admin Group"> The Super Admin Group</a></li>
11           </ul>
12         </li>
13         <li><a href="#Restricting Access"> Restricting Access</a><ul>
14             <li><a href="#Controlling access to a Web"> Controlling access to a Web</a></li>
15             <li><a href="#Controlling access to a Topic"> Controlling access to a Topic</a></li>
16             <li><a href="#Controlling access to Attachment"> Controlling access to Attachments</a></li>
17             <li><a href="#Controlling who can create top-l"> Controlling who can create top-level webs</a></li>
18             <li><a href="#How TWiki evaluates ALLOW/DENY s"> How TWiki evaluates ALLOW/DENY settings</a></li>
19           </ul>
20         </li>
21         <li><a href="#Access Control quick recipes"> Access Control quick recipes</a><ul>
22             <li><a href="#Obfuscating Webs"> Obfuscating Webs</a></li>
23             <li><a href="#Authenticate all Webs and Restri"> Authenticate all Webs and Restrict Selected Webs</a></li>
24             <li><a href="#Authenticate and Restrict Select"> Authenticate and Restrict Selected Webs Only</a></li>
25             <li><a href="#Hide Control Settings"> Hide Control Settings</a></li>
26           </ul>
27         </li>
28       </ul>
29     </li>
30   </ul>
31 </div>
32
33 # <a name="TWiki Access Control"></a> TWiki Access Control
34
35 _Restricting read and write access to topics and webs, by Users and groups_
36
37 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.
38
39 **_%T% Tip:_** TWiki:TWiki.TWikiAccessControlSupplement on TWiki.org has additional documentation on access control.
40
41 <a name="ImportantConsideration"></a>
42
43 ## <a name="An Important Control Considerati"></a> An Important Control Consideration
44
45 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:
46
47 - **Peer influence** is enough to ensure that only relevant content is posted.
48 - **Peer editing** - the ability for anyone to rearrange all content on a page - keeps topics focused.
49 - In TWiki, content is transparently preserved under **revision control**:
50   - Edits can be undone by the [[TWikiAdminGroup]] (the default administrators group; see [[#ManagingGroups|Main/WebHome#ManagingGroups]]).
51   - Users are encouraged to edit and refactor (condense a long topic), since there's a safety net.
52
53 As a **collaboration guideline**:
54
55 - Create broad-based Groups (for more and varied input), and...
56 - Avoid creating view-only Users (if you can read it, you should be able to contribute to it).
57
58 ## <a name="Permissions settings of the webs"></a> Permissions settings of the webs on this TWiki site
59
60 **_Note:_** Above table comes from [[SitePermissions]]
61
62 ## <a name="Authentication vs. Access Contro"></a> Authentication vs. Access Control
63
64 **Authentication:** Identifies who a user is based on a login procedure. See [[TWikiUserAuthentication]].
65
66 **Access control:** Restrict access to content based on users and groups once a user is identified.
67
68 ## <a name="Users and Groups"></a> Users and Groups
69
70 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.
71
72 ### <a name="Managing Users"></a> Managing Users
73
74 A user can create an account in [[TWikiRegistration]]. The following actions are performed:
75
76 - [[WikiName]] and encrypted password are recorded using the password manager if authentication is enabled.
77 - A confirmation e-mail is sent to the user.
78 - A user home page with the [[WikiName]] of the user is created in the Main web.
79 - The user is added to the [[TWikiUsers]] topic.
80
81 The default visitor name is [[TWikiGuest]]. This is the non-authenticated user.
82
83 <a name="ManagingGroups"></a>
84
85 ### <a name="Managing Groups"></a> Managing Groups
86
87 Groups are defined by group topics located in the <code>**Main**</code> web, such as the [[TWikiAdminGroup]]. To create a new group, visit [[TWikiGroups]] and enter the name of the new group ending in <code>**Group**</code> into the "new group" form field. This will create a new group topic with two important settings:
88
89 - <code>**Set GROUP = &lt; list of Users and/or Groups &gt;**</code>
90 - <code>**Set ALLOWTOPICCHANGE = &lt; list of Users and/or Groups &gt;**</code>
91
92 The GROUP setting is a comma-separated list of users and/or other groups. Example:
93
94 - <code>**Set GROUP = Main.SomeUser, Main.OtherUser, Main.SomeGroup**</code>
95
96 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 TWikiAdminGroup topic write:
97
98 - <code>**Set ALLOWTOPICCHANGE = Main.TWikiAdminGroup**</code>
99
100 **_%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.
101
102 <a name="SuperAdminGroup"></a>
103
104 ### <a name="The Super Admin Group"></a> The Super Admin Group
105
106 By mistyping a user or group name in the settings, it's possible to lock a topic so that no-one can edit it from a browser. To avoid this, add the [[WikiNames]] of registered administrators to the super admin group topic called <code>**TWikiAdminGroup**</code>. The name of this topic is defined by the \{SuperAdminGroup\} [configure](http://www.dementia.org/twiki/configure) setting. Example group setting:
107
108 - <code>**Set GROUP= Main.ElizabethWindsor, Main.TonyBlair**</code>
109
110 ## <a name="Restricting Access"></a> Restricting Access
111
112 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.
113
114 - Restricting VIEW blocks viewing and searching of content.
115 - Restricting CHANGE blocks creating new topics, changing topics or attaching files.
116
117 ### <a name="Controlling access to a Web"></a> Controlling access to a Web
118
119 You can define restrictions on who is allowed to view a %WIKITOOLNAME% web. You can restrict access to certain webs to selected Users and Groups, by:
120
121 - **authenticating all webs and restricting selected webs:** Topic access in all webs is authenticated, and selected webs have restricted access.
122 - **authenticating and restricting selected webs only:** Provide unrestricted viewing access to open webs, with authentication and restriction only on selected webs.
123
124 - You can define these settings in the [[WebPreferences]] topic, preferable towards the end of the topic:
125   - <code>**Set DENYWEBVIEW = &lt; comma-delimited list of Users and Groups &gt;**</code>
126   - <code>**Set ALLOWWEBVIEW = &lt; comma-delimited list of Users and Groups &gt;**</code>
127   - <code>**Set DENYWEBCHANGE = &lt; comma-delimited list of Users and Groups &gt;**</code>
128   - <code>**Set ALLOWWEBCHANGE = &lt; comma-delimited list of Users and Groups &gt;**</code>
129
130 **Be careful** with empty values for any of these. In older versions of TWiki,
131
132 - <code>**Set ALLOWWEBVIEW = **</code>
133
134 meant the same as not setting it at all. However since TWiki Dakar release, it means _allow noone access_ i.e. prevent anyone from viewing the web. Similarly
135
136 - <code>**Set DENYWEBVIEW = **</code>
137
138 now means _do not deny anyone the right to view this web_. See "How TWiki evaluates ALLOW/DENY settings" below for more on this.
139
140 ### <a name="Controlling access to a Topic"></a> Controlling access to a Topic
141
142 - You can define these settings in any topic, preferable towards the end of the topic:
143   - <code>**Set DENYTOPICVIEW = &lt; comma-delimited list of Users and Groups &gt;**</code>
144   - <code>**Set ALLOWTOPICVIEW = &lt; comma-delimited list of Users and Groups &gt;**</code>
145   - <code>**Set DENYTOPICCHANGE = &lt; comma-delimited list of Users and Groups &gt;**</code>
146   - <code>**Set ALLOWTOPICCHANGE = &lt; comma-delimited list of Users and Groups &gt;**</code>
147
148 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.
149
150 **Be careful** with empty values for any of these. In older versions of TWiki,
151
152 - <code>**Set ALLOWTOPICVIEW = **</code>
153
154 meant the same as not setting it at all. However since TWiki Dakar release, it means _allow no-one access_ i.e. prevent anyone from viewing the topic. Similarly
155
156 - <code>**Set DENYTOPICVIEW = **</code>
157
158 now means _do not deny anyone the right to view this topic_. See "How TWiki evaluates ALLOW/DENY settings" below for more on this.
159
160 ### <a name="Controlling access to Attachment"></a> Controlling access to Attachments
161
162 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.
163
164 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,
165
166         ScriptAlias /twiki/bin/ /filesystem/path/to/twiki/bin/
167         Alias /twiki/pub/       /filesystem/path/to/twiki/pub/
168
169         RewriteEngine on
170         RewriteCond %{REQUEST_URI} !^/+twiki/+pub/+TWiki/+.+
171         RewriteRule ^/+twiki/+pub/+([^/]+)/+((([^/]+)/+)+)(.+) /twiki/bin/viewfile/$1/$4?filename=$5 [L,PT]
172
173 That way all the controls that apply to the topic also apply to attachments to the topic. Other types of webserver have similar support.
174
175 **_Note:_** Images embedded in topics will load much slower since each image will be delivered by the `viewfile` script.
176
177 ### <a name="Controlling who can create top-l"></a> Controlling who can create top-level webs
178
179 Top level webs are a special case, because they don't have a parent web with a [[WebPreferences]]. So there has to be a special control just for the root level.
180
181 - You can define these settings in the Main.%TWIKIPREFSTOPIC% topic, preferable towards the end of the topic:
182   - <code>**Set DENYROOTCHANGE = &lt; comma-delimited list of Users and Groups &gt;**</code>
183   - <code>**Set ALLOWROOTCHANGE = &lt; comma-delimited list of Users and Groups &gt;**</code>
184
185 Note that you do **not** require `ROOTCHANGE` access to rename an existing top-level web. You just need `WEBCHANGE` in the web itself.
186
187 ### <a name="How TWiki evaluates ALLOW/DENY s"></a> How TWiki evaluates ALLOW/DENY settings
188
189 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 and CHANGE access may be granted/denied separately.
190
191 1. If the user is a [[super-user|Main/WebHome#SuperAdminGroup]]
192   - access is **PERMITTED**.
193 2. If DENYTOPIC is set to a list of wikinames
194   - people in the list will be **DENIED**.
195 3. If DENYTOPIC is set to _empty_ ( i.e. `Set DENYTOPIC =` )
196   - access is **PERMITTED** _i.e_ no-one is denied access to this topic
197 4. If ALLOWTOPIC is set
198   1. people in the list are **PERMITTED**
199   2. everyone else is **DENIED**
200     - Note that this means that setting ALLOWTOPIC to empty _denies access to everyone except admins_ (unless DENYTOPIC is also set to empty, as described above)
201 5. If DENYWEB is set to a list of wikiname
202   - people in the list are **DENIED** access
203 6. If ALLOWWEB is set to a list of wikinames
204   - people in the list will be **PERMITTED**
205   - everyone else will be **DENIED**
206     - Note that setting ALLOWWEB to empty _denies access to everyone except admins_
207 7. If you got this far, access is **PERMITTED**
208
209 ## <a name="Access Control quick recipes"></a> Access Control quick recipes
210
211 ### <a name="Obfuscating Webs"></a> Obfuscating Webs
212
213 Another way of hiding webs is to keep them hidden by not publishing the URL and by preventing the <code>**all webs**</code> search option from accessing obfuscated webs. Do so by enabling the <code>**NOSEARCHALL**</code> variable in [[WebPreferences]]:
214
215 - <code>**Set NOSEARCHALL = on**</code>
216
217 This setup can be useful to hide a new web until content its ready for deployment, or to hide view access restricted webs.
218
219 **_%X% Note:_** Obfuscating a web without view access control is **very** insecure, as anyone who knows the URL can access the web.
220
221 ### <a name="Authenticate all Webs and Restri"></a> Authenticate all Webs and Restrict Selected Webs
222
223 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.
224
225 1. **Restrict** view access to selected Users and Groups. Set one or both of these variables in its [[WebPreferences]] topic:
226   - <code>**Set DENYWEBVIEW = &lt; list of Users and Groups &gt;**</code>
227   - <code>**Set ALLOWWEBVIEW = &lt; list of Users and Groups &gt;**</code>
228   - **_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 in case `DENYWEBVIEW` and `ALLOWWEBVIEW` is not defined.
229
230 ### <a name="Authenticate and Restrict Select"></a> Authenticate and Restrict Selected Webs Only
231
232 Use the following setup to provide unrestricted viewing access to open webs, with authentication only on selected webs. Requires [[TWikiUserAuthentication]] to be enabled.
233
234 1. **Restrict** view access to selected Users and Groups. Set one or both of these variables in its [[WebPreferences]] topic:
235   - <code>**Set DENYWEBVIEW = &lt; list of Users and Groups &gt;**</code>
236   - <code>**Set ALLOWWEBVIEW = &lt; list of Users and Groups &gt;**</code>
237   - **_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 in case `DENYWEBVIEW` and `ALLOWWEBVIEW` is not defined.
238
239 ### <a name="Hide Control Settings"></a> Hide Control Settings
240
241 **_%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|Main/TWikiVariables#Setting_Preferences_Variables]].
242
243 Alternatively, place them in HTML comment markers, but this exposes the access setting during ordinary editing.
244
245 > <code>**&lt;!--**</code>
246 >
247 > <br />
248 >
249 > <code>**   \* Set DENYTOPICCHANGE = Main.SomeGroup**</code>
250 >
251 > <br />
252 >
253 > <code>**--&gt;**</code>
254
255 **_Related Topics:_** [[AdminDocumentationCategory]], [[TWikiUserAuthentication]], TWiki:TWiki.TWikiAccessControlSupplement
256
257 -- **_Contributors:_** TWiki:Main.PeterThoeny, TWiki:Main.MikeMannix, TWiki:Main.CrawfordCurrie