Commit 51d780c9 authored by Georg Gogo. BERNHARD's avatar Georg Gogo. BERNHARD

Fixing permission handling by using hashed names instead of columns and rows (#59)

parent 5b6a9672
...@@ -81,7 +81,7 @@ a permission in addition to selecting to acquire permissions. ...@@ -81,7 +81,7 @@ a permission in addition to selecting to acquire permissions.
<dtml-unless isTopLevelPrincipiaApplicationObject> <dtml-unless isTopLevelPrincipiaApplicationObject>
<td align="left" valign="top"> <td align="left" valign="top">
<input type="checkbox" name="a&dtml-sequence-index;" &dtml-acquire; /> <input type="checkbox" name="acquire_&dtml-hashed_name;" &dtml-acquire; />
</td> </td>
</dtml-unless> </dtml-unless>
<td align="left" nowrap> <td align="left" nowrap>
......
...@@ -25,6 +25,7 @@ from AccessControl.rolemanager import reqattr ...@@ -25,6 +25,7 @@ from AccessControl.rolemanager import reqattr
from AccessControl.Permission import Permission from AccessControl.Permission import Permission
from AccessControl.Permissions import change_permissions from AccessControl.Permissions import change_permissions
from AccessControl.requestmethod import requestmethod from AccessControl.requestmethod import requestmethod
from AccessControl.rolemanager import _string_hash
class RoleManager(BaseRoleManager): class RoleManager(BaseRoleManager):
...@@ -104,14 +105,18 @@ class RoleManager(BaseRoleManager): ...@@ -104,14 +105,18 @@ class RoleManager(BaseRoleManager):
permissions=self.ac_inherited_permissions(1) permissions=self.ac_inherited_permissions(1)
fails = [] fails = []
for ip in range(len(permissions)): for ip in range(len(permissions)):
permission_name = permissions[ip][0]
permission_hash = _string_hash(permission_name)
roles = [] roles = []
for ir in indexes: for role in valid_roles:
if have("p%dr%d" % (ip, ir)): role_name = role
roles.append(valid_roles[ir]) role_hash = _string_hash(role_name)
if have("permission_%srole_%s" % (permission_hash, role_hash)):
roles.append(role)
name, value = permissions[ip][:2] name, value = permissions[ip][:2]
try: try:
p = Permission(name, value, self) p = Permission(name, value, self)
if not have('a%d' % ip): if not have('acquire_%s' % permission_hash):
roles=tuple(roles) roles=tuple(roles)
p.setRoles(roles) p.setRoles(roles)
except: except:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment