Skip to content

Commit b0d687f

Browse files
author
Richard Jones
committed
Very close now. The cgi and mailgw now use the new security API.
The two templates have been migrated to that setup. Lots of unit tests. Still some issue in the web form for editing Roles assigned to users.
1 parent 2139d8a commit b0d687f

21 files changed

+606
-261
lines changed

COPYING.txt

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,26 @@
11

2-
Copyright (c) 2001 Bizar Software Pty Ltd (http://www.bizarsoftware.com.au/)
32
Copyright (c) 2002 eKit.com Inc (http://www.ekit.com/)
43

4+
Permission is hereby granted, free of charge, to any person obtaining a copy
5+
of this software and associated documentation files (the "Software"), to deal
6+
in the Software without restriction, including without limitation the rights
7+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
copies of the Software, and to permit persons to whom the Software is
9+
furnished to do so, subject to the following conditions:
10+
11+
The above copyright notice and this permission notice shall be included in
12+
all copies or substantial portions of the Software.
13+
14+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20+
SOFTWARE.
21+
22+
Copyright (c) 2001 Bizar Software Pty Ltd (http://www.bizarsoftware.com.au/)
23+
524
This module is free software, and you may redistribute it and/or modify
625
under the same terms as Python, so long as this copyright message and
726
disclaimer are retained in their original form.
@@ -17,7 +36,6 @@ FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS"
1736
BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1837
SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1938

20-
2139
The stylesheet included with this package has been copied from the Zope
2240
management interface and presumably belongs to Digital Creations.
2341

doc/security.txt

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Security Mechanisms
33
===================
44

5-
:Version: $Revision: 1.12 $
5+
:Version: $Revision: 1.13 $
66

77
Current 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

248248
In 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
261259
to 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::
279277
where:
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
293291
A 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

299296
The default interfaces define:
300297

@@ -303,18 +300,24 @@ The default interfaces define:
303300

304301
These 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

310307
And finally, the "admin" user gets the "Admin" Role, and the "anonymous" user
311308
gets the "Anonymous" assigned when the database is initialised on installation.
312309
The 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

320323
Authentication 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

doc/upgrading.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ TODO: mention that the dbinit needs the db.post_init() method call for
1818
reindexing
1919
TODO: dbinit now imports classes from selct_db
2020
TODO: select_db needs fixing to include Class, FileClass and IssueClass
21+
TODO: migration of security settings
2122

2223

2324
Migrating from 0.4.1 to 0.4.2

roundup/backends/back_anydbm.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
#$Id: back_anydbm.py,v 1.53 2002-07-25 07:14:06 richard Exp $
18+
#$Id: back_anydbm.py,v 1.54 2002-07-26 08:26:59 richard Exp $
1919
'''
2020
This module defines a backend that saves the hyperdatabase in a database
2121
chosen by anydbm. It is guaranteed to always be available in python
@@ -1333,7 +1333,7 @@ def stringFind(self, **requirements):
13331333
if node.has_key(self.db.RETIRED_FLAG):
13341334
continue
13351335
for key, value in requirements.items():
1336-
if node[key] and node[key].lower() != value:
1336+
if node[key] is None or node[key].lower() != value:
13371337
break
13381338
else:
13391339
l.append(nodeid)
@@ -1776,6 +1776,14 @@ def __init__(self, db, classname, **properties):
17761776

17771777
#
17781778
#$Log: not supported by cvs2svn $
1779+
#Revision 1.53 2002/07/25 07:14:06 richard
1780+
#Bugger it. Here's the current shape of the new security implementation.
1781+
#Still to do:
1782+
# . call the security funcs from cgi and mailgw
1783+
# . change shipped templates to include correct initialisation and remove
1784+
# the old config vars
1785+
#... that seems like a lot. The bulk of the work has been done though. Honest :)
1786+
#
17791787
#Revision 1.52 2002/07/19 03:36:34 richard
17801788
#Implemented the destroy() method needed by the session database (and possibly
17811789
#others). At the same time, I removed the leading underscores from the hyperdb

0 commit comments

Comments
 (0)