22Security Mechanisms
33===================
44
5- :Version: $Revision: 1.12 $
5+ :Version: $Revision: 1.13 $
66
77Current situation
88=================
@@ -184,7 +184,7 @@ A security module defines::
184184 base roles (for admin user).
185185 '''
186186
187- def hasClassPermission (self, db, classname, permission, userid):
187+ def hasPermission (self, db, classname, permission, userid):
188188 ''' Look through all the Roles, and hence Permissions, and see if
189189 "permission" is there for the specified classname.
190190
@@ -241,26 +241,24 @@ The instance dbinit module then has in ``open()``::
241241 ei = db.security.addPermission(name="Edit", klass="issue",
242242 description="User is allowed to edit issues")
243243 db.security.addPermissionToRole('User', ei)
244- ai = db.security.addPermission(name="Assign ", klass="issue",
245- description="User may be assigned to issues")
246- db.security.addPermissionToRole('User', ei )
244+ ai = db.security.addPermission(name="View ", klass="issue",
245+ description="User is allowed to access issues")
246+ db.security.addPermissionToRole('User', ai )
247247
248248In the dbinit ``init()``::
249249
250+ # create the two default users
250251 r = db.getclass('role').lookup('Admin')
251252 user.create(username="admin", password=Password(adminpw),
252- address=instance_config.ADMIN_EMAIL, roles=[r])
253-
254- # choose your anonymous user access permission here
255- #r = db.getclass('role').lookup('No Rego')
256- r = db.getclass('role').lookup('User')
257- user.create(username="anonymous", roles=[r])
253+ address=instance_config.ADMIN_EMAIL, roles='Admin')
254+ r = db.getclass('role').lookup('Anonymous')
255+ user.create(username="anonymous", roles='Anonymous')
258256
259- Then in the code that matters, calls to ``hasClassPermission `` and
257+ Then in the code that matters, calls to ``hasPermission `` and
260258``hasNodePermission`` are made to determine if the user has permission
261259to perform some action::
262260
263- if db.security.hasClassPermission ('issue', 'Edit', userid):
261+ if db.security.hasPermission ('issue', 'Edit', userid):
264262 # all ok
265263
266264 if db.security.hasNodePermission('issue', nodeid, assignedto=userid):
@@ -279,7 +277,7 @@ which has the form::
279277where:
280278
281279- the permission attribute gives a comma-separated list of permission names.
282- These are checked in turn using ``hasClassPermission `` and requires one to
280+ These are checked in turn using ``hasPermission `` and requires one to
283281 be OK.
284282- the other attributes are lookups on the node using ``hasNodePermission``. If
285283 the attribute value is "$userid" then the current user's userid is tested.
@@ -293,8 +291,7 @@ Implementation as shipped
293291A set of Permissions are built in to the security module by default:
294292
295293- Edit (everything)
296- - Access (everything)
297- - Assign (everything)
294+ - View (everything)
298295
299296The default interfaces define:
300297
@@ -303,18 +300,24 @@ The default interfaces define:
303300
304301These are hooked into the default Roles:
305302
306- - Admin (Edit everything, Access everything, Assign everything)
303+ - Admin (Edit everything, View everything)
307304- User ()
308305- Anonymous (Web Registration, Email Registration)
309306
310307And finally, the "admin" user gets the "Admin" Role, and the "anonymous" user
311308gets the "Anonymous" assigned when the database is initialised on installation.
312309The two default schemas then define:
313310
314- - Edit issue, Access issue (both)
315- - Edit support, Access support (extended only)
311+ - Edit issue, View issue (both)
312+ - Edit file, View file (both)
313+ - Edit msg, View msg (both)
314+ - Edit support, View support (extended only)
315+
316+ and assign those Permissions to the "User" Role. New users are assigned the
317+ Roles defined in the config file as:
316318
317- and assign those Permissions to the "User" Role.
319+ - NEW_WEB_USER_ROLES
320+ - NEW_EMAIL_USER_ROLES
318321
319322
320323Authentication of Users
@@ -354,6 +357,7 @@ The CGI interface must be changed to:
354357 - implement htmltemplate tests on permissions
355358 - switch all code over from using config vars for permission checks to using
356359 permissions
360+ - change all explicit admin user checks for Role checks
357361 - include config vars for initial Roles for anonymous web, new web and new
358362 email users
359363
0 commit comments