none
[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="#Users and Groups"> Users and Groups</a><ul>
6             <li><a href="#Managing Users"> Managing Users</a></li>
7             <li><a href="#Managing Groups"> Managing Groups</a></li>
8           </ul>
9         </li>
10         <li><a href="#Restricting Write Access"> Restricting Write Access</a><ul>
11             <li><a href="#Deny Editing by Topic"> Deny Editing by Topic</a></li>
12             <li><a href="#Deny Editing by Web"> Deny Editing by Web</a></li>
13           </ul>
14         </li>
15         <li><a href="#Restricting Rename Access"> Restricting Rename Access</a><ul>
16             <li><a href="#Deny Renaming by Topic"> Deny Renaming by Topic</a></li>
17             <li><a href="#Deny Renaming by Web"> Deny Renaming by Web</a></li>
18           </ul>
19         </li>
20         <li><a href="#Restricting Web Access"> Restricting Web Access</a><ul>
21             <li><a href="#Create Hidden Webs"> Create Hidden Webs</a></li>
22             <li><a href="#Create Authenticated Access By W"> Create Authenticated Access By Web</a></li>
23           </ul>
24         </li>
25         <li><a href="#Hiding Control Settings"> Hiding Control Settings</a></li>
26         <li><a href="#The _SuperAdminGroup"> The SuperAdminGroup</a></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 [[TWikiAccessControl]] allows you restrict access to single topics and entire webs, by individual user and by user groups, in three main areas: view; edit &amp; attach; and rename/move/delete. These controls, combined with [[TWikiUserAuthentication]], let you easily create and manage an extremely flexible, fine-grained privilege system.
37
38 ## <a name="An Important Control Considerati"></a> An Important Control Consideration
39
40 Open, freeform editing is the essence of the [[WikiCulture]] - it's what makes TWiki different and often more effective than other collaboration tools. So, it is strongly recommended that decisions to restrict read or write access to a web or a topic are made with care. Experience shows that _unrestricted write access_ works very well because:
41
42 - Peer influence is enough to ensure that only relevant content is posted.
43
44 - Peer editing - the ability to rearrange anything on a page - keeps topics focussed.
45
46 - All content is preserved under revision control.
47   - Edits can be undone by the [[TWikiAdminGroup]] (the default administrators group; see #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 groups (more and varied input), and...
53 - Avoid creating view-only users (if you can read it, you can contribute to it).
54
55 ## <a name="Users and Groups"></a> Users and Groups
56
57 Access control is based on users and groups. Users are defined by their [[WikiNames]], an then organized in unlimited combinations under different user groups.
58
59 ### <a name="Managing Users"></a> Managing Users
60
61 A user is created by with the [[TWikiRegistration]] form. The process generates a topic in the Main web in the new user's [[WikiName]]. The default visitor name is [[TWikiGuest]].
62
63 - Users can be authenticated using Basic Authentication or SSL. [[TWikiUserAuthentication]] is required in order to track user identities.
64
65 <a name="ManagingGroups"></a>
66
67 ### <a name="Managing Groups"></a> Managing Groups
68
69 Groups are defined by group topics in the <code>**Main**</code> web, like the [[TWikiAdminGroup]]. To start a new group:
70
71 1. **Create** a new topic with A name that ends in **Group**, `SomeGroup`
72 2. **Define** two variables:
73   - Set GROUP = &lt; list of users and groups &gt;
74   - Set ALLOWTOPICCHANGE = &lt; list of users and groups &gt;
75
76 - GROUP is a comma-separated list of users and of other groups:<br /><code>**    Set GROUP = Main.SomeUser, Main.OtherUser, Main.SomeOtherGroup**</code>
77
78 - ALLOWTOPICCHANGE 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,<br /><code>**    Set ALLOWTOPICCHANGE = Main.TWikiAdminGroup**</code><br /> for the TWikiAdminGroup topic. (This prevents users not in the group from editing the topic and from gaining unauthorized membership to the group.)
79
80 ## <a name="Restricting Write Access"></a> Restricting Write Access
81
82 You can define who is allowed to make changes to a web or a topic.
83
84 ### <a name="Deny Editing by Topic"></a> Deny Editing by Topic
85
86 Denying editing of a topic also restricts attaching files to it; both privileges are assigned together.
87
88 - Define one or both of these variables in a topic, preferably at the end of the page:
89   - Set DENYTOPICCHANGE = &lt; list of users and groups &gt;
90   - Set ALLOWTOPICCHANGE = &lt; list of users and groups &gt;
91
92 - DENYTOPICCHANGE defines users or groups that **are not** allowed to make changes to the topic. It is a comma delimited list of users and groups. Example: <br />`    * Set DENYTOPICCHANGE = Main.SomeBadBoy, Main.SomeBadGirl, Main.SomeHackerGroup`
93
94 - ALLOWTOPICCHANGE defines users or groups that **are** allowed to make changes to the topic. It is a comma delimited list of users and groups. Example: <br />`    * Set ALLOWTOPICCHANGE = Main.SomeGoodGuy, Main.SomeGoodGirl, Main.TWikiAdminGroup`
95
96 - DENYTOPICCHANGE is evaluated before ALLOWTOPICCHANGE. Access is denied if the authenticated person is in the DENYTOPICCHANGE list, or not in the ALLOWTOPICCHANGE list. Access is granted in case DENYTOPICCHANGE and ALLOWTOPICCHANGE is not defined.
97
98 ### <a name="Deny Editing by Web"></a> Deny Editing by Web
99
100 Restricting web-level editing blocks creating new topics, changing topics or attaching files.
101
102 - Define one or both of these variable in the [[WebPreferences]] topic:
103   - Set DENYWEBCHANGE = &lt; list of users and groups &gt;
104   - Set ALLOWWEBCHANGE = &lt; list of users and groups &gt;
105
106 The same rules apply as for restricting topics, with these additions:
107
108 - DENYTOPICCHANGE (in topic) overrides DENYWEBCHANGE (in WebPreferences)
109 - ALLOWTOPICCHANGE (in topic) overrides ALLOWWEBCHANGE (in WebPreferences)
110
111 ## <a name="Restricting Rename Access"></a> Restricting Rename Access
112
113 You can define who is allowed to rename, move or delete a topic, or rename a web.
114
115 ### <a name="Deny Renaming by Topic"></a> Deny Renaming by Topic
116
117 To allow a user to rename, move or delete a topic, they also need write (editing) permission. They also need write access to change references in referring topics.
118
119 - Define one or both of these variables in a topic, preferably at the end of the topic:
120   - Set DENYTOPICRENAME = &lt; list of users and groups &gt;
121   - Set ALLOWTOPICRENAME = &lt; list of users and groups &gt;
122
123 - DENYTOPICCRENAME defines users or groups that **are not** allowed to rename the topic. It is a comma delimited list of users and groups. Example: <br />`    * Set DENYTOPICRENAME = Main.SomeBadBoy, Main.SomeBadGirl, Main.SomeHackerGroup`
124
125 - ALLOWTOPICRENAME defines users or groups that **are** allowed to rename the topic. It is a comma delimited list of users and groups. Example: <br />`    * Set ALLOWTOPICRENAME = Main.SomeGoodGuy, Main.SomeGoodGirl, Main.TWikiAdminGroup`
126
127 - DENYTOPICRENAME is evaluated before ALLOWTOPICRENAME. Access is denied if the authenticated person is in the DENYTOPICRENAME list, or not in the ALLOWTOPICRENAME list. Access is granted in case DENYTOPICRENAME and ALLOWTOPICRENAME is not defined.
128
129 ### <a name="Deny Renaming by Web"></a> Deny Renaming by Web
130
131 You can define restrictions of who is allowed to rename a %WIKITOOLNAME% web.
132
133 - Define one or both of these variable in the [[WebPreferences]] topic:
134   - Set DENYWEBRENAME = &lt; list of users and groups &gt;
135   - Set ALLOWWEBRENAME = &lt; list of users and groups &gt;
136
137 The same rules apply as for topics, with these additions:
138
139 - DENYTOPICRENAME (in topic) overrides DENYWEBRENAME (in WebPreferences)
140 - ALLOWTOPICRENAME (in topic) overrides ALLOWWEBRENAME (in WebPreferences)
141
142 ## <a name="Restricting Web Access"></a> Restricting Web Access
143
144 You can prevent selected users and groups from accessing certain webs, by hiding them using restricting read access, or by requiring login. There are two basic methods, one simple, using standard preferences variables to hide a web, but offering low security, and a secure log-in approach that is currently a workaround, involving some minor script and filesystem modification.
145
146 ### <a name="Create Hidden Webs"></a> Create Hidden Webs
147
148 You can prevent selected users and groups from viewing certain %WIKITOOLNAME% webs by setting one or both of these variables in each web's [[WebPreferences]] topic:
149
150 - - Set DENYWEBVIEW = &lt; list of users and groups &gt;
151   - Set ALLOWWEBVIEW = &lt; list of users and groups &gt;
152 - If keeping a hidden web out of general use is a consideration, you should also prevent the "all webs" search option from accessing each hidden web, by enabling the <code>**NOSEARCHALL**</code> variable in [[WebPreferences]]:
153   - Set NOSEARCHALL = on
154   - It is not recommended to restrict view access to individual topics since all content is searchable _within_ a web.
155 - %H%This method only works if the <code>**view**</code> script is authenticated, which means that all users have to login, even for read-only access. (An open guest account, like [[TWikiGuest]], can get around this, allowing anyone to login with, for example, view-only access for public webs.) [[TWikiInstallationGuide]] has more on Basic Authentication, using the <code>**.htaccess**</code> file.
156 - %X% **Hiding webs is not very secure**, as there is a way to circumvent the read access restriction. It can be useful in certain situations - for example, to simplify site organization and clutter, by hiding low traffic webs - but is not recommended for securing sensitive content.
157
158 ### <a name="Create Authenticated Access By W"></a> Create Authenticated Access By Web
159
160 To selectively restrict web access with the security of Basic Authentication, there is a reliable workaround that involves some straightforward code modification:
161
162 1. Set aside the <code>**view**</code> script (rename) and create a <code>**view**</code> subdirectory in its place.
163 2. In the <code>**view**</code> subdirectory, create a separate copy of a modified viewing script for each web, and create <code>**.htaccess**</code> settings for the restricted webs.
164   - %T% You can use symbolic links to a single copy of the viewing script to make any script updates that much easier.
165
166 > **Example of viewing script**
167 >
168 > <code>**redirect**</code>
169 >
170 >     #!/usr/bin/perl -w
171 >     #
172 >
173 >     chdir '..';
174 >
175 >     # Adjust SCRIPT and PATH_INFO variables to account for the changed directory
176 >     my $web = $ENV{SCRIPT_NAME};
177 >     $web    =~ s#^.*/view(/[^/]*).*$#$1#; # isolate the path element after "view"
178 >     $ENV{PATH_TRANSLATED} =~ s#(/[^/]*)$#$web$1#;
179 >     $ENV{PATH_INFO}       =~ s#(/[^/]*)$#$web$1#;
180 >     $ENV{SCRIPT_NAME}     =~ s#/view$web#/view#;
181 >     $ENV{SCRIPT_FILENAME} =~ s#/view$web#/view#;
182 >
183 >     # open (LOG, '>>/tmp/redirect.log');
184 >     # print LOG join ("\n", scalar localtime (time ()), %ENV);
185 >     # close LOG;
186 >     exec ('/usr/bin/perl', '-wT', 'view.orig') or
187 >
188 >     print <<EOF;
189 >     Content-type: text/plain
190 >
191 >     Error executing /cgi-bin/view.orig: $?
192 >     Click the BACK button in your browser and contact webmaster\@bcs-oops.org.
193 >
194 >     EOF
195
196 - **_(Mod by [[ImmoHuneke]] - 16 Mar 2002)_**
197
198 **A SECOND OPTION:** A less reliable workaround that also requires code changes is available to provide the same unrestricted viewing access, with authentication required only on selected webs:
199
200 1. **Omit** the <code>**view**</code> script from the `.htaccess` file.
201 2. **Enable** the <code>**$doRememberRemoteUser**</code> flag in <code>**lib/TWiki.cfg**</code> as described in [[TWikiUserAuthentication]]. %WIKITOOLNAME% will now remember the IP address of an authenticated user. 1. **Copy** the <code>**view**</code> script to <code>**viewauth**</code> (or better, create a symbolic link) 1. **Add** <code>**viewauth**</code> to the list of authenticated scripts in the .htaccess file.
202   - When a user accesses a web where you enabled view restriction, %WIKITOOLNAME% will redirect from the `view` script to the `viewauth` script once (this happens only if the user has never edited a topic). Doing so will ask for authentication. The `viewauth` script shows the requested topic if the user could log on and if the user is authorized to see that web.
203   - If you enable view restriction for a web, it is recommended to restrict search "all webs" from searching this web. Enable this restriction with the <code>**NOSEARCHALL**</code> variable in its [[WebPreferences]], like:
204     - Set NOSEARCHALL = on
205   - It is not recommended to restrict view access to individual topics since all content is searchable _within_ a web.
206
207 ## <a name="Hiding Control Settings"></a> Hiding Control Settings
208
209 - %T% To hide access control settings from normal browser viewing, place them in comment markers.
210
211 > &lt;!--
212 >
213 > <br />
214 >
215 > Set DENYTOPICCHANGE = Main.SomeGroup
216 >
217 > <br />
218 >
219 > --&gt;
220
221 <a name="SuperAdminGroup"></a>
222
223 ## <a name="The _SuperAdminGroup"></a> The SuperAdminGroup
224
225 By mistyping a user or group name in the ALLOWTOPICCHANGE setting, it's possible to lock a topic so that it no-one can edit it from a browser. To avoid this:
226
227 - Set the `$superAdminGroup` variable in `lib/TWiki.cfg` to the name of a group of users that are always allowed to edit/view topics.
228
229 > $superAdminGroup = "TWikiAdminGroup";
230
231 - The default setting is not to have superusers.
232
233 -- [[MikeMannix]] - 20 Mar 2002