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