Skip to content

Commit 0ef71a2

Browse files
author
Richard Jones
committed
fix permission checks in cgi interface [SF#1289557]
1 parent 18d6235 commit 0ef71a2

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

CHANGES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ Fixed:
4747
- fix Date: header generation to be LOCALE-agnostic (sf bug 1352624)
4848
- fix admin doc description of roundup-server config file
4949
- fix redirect after instant registration (sf bug 1381676)
50+
- fix permission checks in cgi interface (sf bug 1289557)
5051

5152

5253
2005-10-07 0.8.5

roundup/cgi/actions.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#$Id: actions.py,v 1.50 2006-01-13 03:33:29 richard Exp $
1+
#$Id: actions.py,v 1.51 2006-01-13 03:50:03 richard Exp $
22

33
import re, cgi, StringIO, urllib, Cookie, time, random, csv
44

@@ -435,7 +435,7 @@ def _editnodes(self, all_props, all_links):
435435
def _changenode(self, cn, nodeid, props):
436436
"""Change the node based on the contents of the form."""
437437
# check for permission
438-
if not self.editItemPermission(props):
438+
if not self.editItemPermission(props, classname=cn, itemid=nodeid):
439439
raise exceptions.Unauthorised, self._(
440440
'You do not have permission to edit %(class)s'
441441
) % {'class': cn}
@@ -447,7 +447,7 @@ def _changenode(self, cn, nodeid, props):
447447
def _createnode(self, cn, props):
448448
"""Create a node based on the contents of the form."""
449449
# check for permission
450-
if not self.newItemPermission(props):
450+
if not self.newItemPermission(props, classname=cn):
451451
raise exceptions.Unauthorised, self._(
452452
'You do not have permission to create %(class)s'
453453
) % {'class': cn}
@@ -461,7 +461,8 @@ def isEditingSelf(self):
461461
return (self.nodeid == self.userid
462462
and self.db.user.get(self.nodeid, 'username') != 'anonymous')
463463

464-
def editItemPermission(self, props):
464+
_cn_marker = []
465+
def editItemPermission(self, props, classname=_cn_marker, itemid=None):
465466
"""Determine whether the user has permission to edit this item.
466467
467468
Base behaviour is to check the user can edit this class. If we're
@@ -475,17 +476,23 @@ def editItemPermission(self, props):
475476
"You do not have permission to edit user roles")
476477
if self.isEditingSelf():
477478
return 1
478-
if self.hasPermission('Edit', itemid=self.nodeid):
479+
if itemid is None:
480+
itemid = self.nodeid
481+
if classname is self._cn_marker:
482+
classname = self.classname
483+
if self.hasPermission('Edit', itemid=itemid, classname=classname):
479484
return 1
480485
return 0
481486

482-
def newItemPermission(self, props):
487+
def newItemPermission(self, props, classname=None):
483488
"""Determine whether the user has permission to create this item.
484489
485490
Base behaviour is to check the user can edit this class. No additional
486491
property checks are made.
487492
"""
488-
return self.hasPermission('Create')
493+
if not classname :
494+
classname = self.client.classname
495+
return self.hasPermission('Create', classname=classname)
489496

490497
class EditItemAction(EditCommon):
491498
def lastUserActivity(self):

0 commit comments

Comments
 (0)