AccessControl 7.6__cp315-cp315-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- AccessControl/AuthEncoding.py +48 -0
- AccessControl/ImplC.py +39 -0
- AccessControl/ImplPython.py +914 -0
- AccessControl/Implementation.py +111 -0
- AccessControl/Owned.py +30 -0
- AccessControl/Permission.py +179 -0
- AccessControl/PermissionMapping.py +165 -0
- AccessControl/PermissionRole.py +19 -0
- AccessControl/Permissions.py +65 -0
- AccessControl/Role.py +34 -0
- AccessControl/SecurityInfo.py +502 -0
- AccessControl/SecurityManagement.py +84 -0
- AccessControl/SecurityManager.py +30 -0
- AccessControl/SimpleObjectPolicies.py +151 -0
- AccessControl/SpecialUsers.py +25 -0
- AccessControl/User.py +54 -0
- AccessControl/ZopeGuards.py +712 -0
- AccessControl/ZopeSecurityPolicy.py +61 -0
- AccessControl/__init__.py +55 -0
- AccessControl/_compat.h +18 -0
- AccessControl/cAccessControl.c +2526 -0
- AccessControl/cAccessControl.cp315-win_amd64.pyd +0 -0
- AccessControl/class_init.py +94 -0
- AccessControl/configure.zcml +5 -0
- AccessControl/frozen.py +57 -0
- AccessControl/interfaces.py +390 -0
- AccessControl/logger_wrapper.py +8 -0
- AccessControl/meta.zcml +52 -0
- AccessControl/metaconfigure.py +61 -0
- AccessControl/owner.py +288 -0
- AccessControl/permissions.zcml +100 -0
- AccessControl/requestmethod.py +96 -0
- AccessControl/rolemanager.py +490 -0
- AccessControl/safe_formatter.py +86 -0
- AccessControl/security.py +203 -0
- AccessControl/tainted.py +195 -0
- AccessControl/tests/__init__.py +0 -0
- AccessControl/tests/actual_python.py +260 -0
- AccessControl/tests/mixed_module/__init__.py +9 -0
- AccessControl/tests/mixed_module/submodule/__init__.py +5 -0
- AccessControl/tests/private_module/__init__.py +5 -0
- AccessControl/tests/private_module/submodule/__init__.py +5 -0
- AccessControl/tests/public_module/__init__.py +11 -0
- AccessControl/tests/public_module/submodule/__init__.py +5 -0
- AccessControl/tests/testClassSecurityInfo.py +192 -0
- AccessControl/tests/testImplementation.py +65 -0
- AccessControl/tests/testModuleSecurity.py +335 -0
- AccessControl/tests/testPermissionMapping.py +12 -0
- AccessControl/tests/testPermissionRole.py +170 -0
- AccessControl/tests/testSecurityManager.py +264 -0
- AccessControl/tests/testZCML.py +489 -0
- AccessControl/tests/testZopeGuards.py +1086 -0
- AccessControl/tests/testZopeSecurityPolicy.py +799 -0
- AccessControl/tests/test_frozen.py +124 -0
- AccessControl/tests/test_owner.py +289 -0
- AccessControl/tests/test_requestmethod.py +138 -0
- AccessControl/tests/test_rolemanager.py +137 -0
- AccessControl/tests/test_safe_formatter.py +226 -0
- AccessControl/tests/test_safeiter.py +59 -0
- AccessControl/tests/test_tainted.py +320 -0
- AccessControl/tests/test_userfolder.py +198 -0
- AccessControl/tests/test_users.py +666 -0
- AccessControl/unauthorized.py +38 -0
- AccessControl/userfolder.py +432 -0
- AccessControl/users.py +502 -0
- accesscontrol-7.6.dist-info/METADATA +474 -0
- accesscontrol-7.6.dist-info/RECORD +71 -0
- accesscontrol-7.6.dist-info/WHEEL +5 -0
- accesscontrol-7.6.dist-info/entry_points.txt +2 -0
- accesscontrol-7.6.dist-info/licenses/LICENSE.txt +44 -0
- accesscontrol-7.6.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
##############################################################################
|
|
2
|
+
#
|
|
3
|
+
# Copyright (c) 2003 Zope Foundation and Contributors.
|
|
4
|
+
#
|
|
5
|
+
# This software is subject to the provisions of the Zope Public License,
|
|
6
|
+
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
|
|
7
|
+
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
|
|
8
|
+
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
9
|
+
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
|
|
10
|
+
# FOR A PARTICULAR PURPOSE.
|
|
11
|
+
#
|
|
12
|
+
##############################################################################
|
|
13
|
+
|
|
14
|
+
"""Controller that can switch between security machinery implementations.
|
|
15
|
+
|
|
16
|
+
This module allows configuration of the security implementation after
|
|
17
|
+
the initial import of the modules. It is intended to allow runtime
|
|
18
|
+
selection of the machinery based on Zope's configuration file.
|
|
19
|
+
|
|
20
|
+
The helper function defined here switches between the 'C' and 'PYTHON'
|
|
21
|
+
security implementations by loading the appropriate implementation
|
|
22
|
+
module and wiring the implementation into the other modules of the
|
|
23
|
+
AccessControl package that defined the various components before this
|
|
24
|
+
module was introduced.
|
|
25
|
+
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
import os
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
PURE_PYTHON = int(os.environ.get('PURE_PYTHON', '0'))
|
|
32
|
+
CAPI = not PURE_PYTHON
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def getImplementationName():
|
|
36
|
+
"""Return the name of the implementation currently being used."""
|
|
37
|
+
return _implementation_name
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def setImplementation(name):
|
|
41
|
+
"""Select the policy implementation to use. The 'name' must be either
|
|
42
|
+
'PYTHON' or 'C'. NOTE: this function is intended to be called
|
|
43
|
+
exactly once, so that the Zope config file can dictate the policy
|
|
44
|
+
implementation to be used. Subsequent calls to this function will
|
|
45
|
+
have no effect!!
|
|
46
|
+
"""
|
|
47
|
+
import sys
|
|
48
|
+
global _implementation_name
|
|
49
|
+
global _implementation_set
|
|
50
|
+
|
|
51
|
+
if _implementation_set:
|
|
52
|
+
return
|
|
53
|
+
|
|
54
|
+
name = name.upper()
|
|
55
|
+
if name == _implementation_name:
|
|
56
|
+
return
|
|
57
|
+
if name == "C":
|
|
58
|
+
from AccessControl import ImplC as impl
|
|
59
|
+
elif name == "PYTHON":
|
|
60
|
+
from AccessControl import ImplPython as impl
|
|
61
|
+
else:
|
|
62
|
+
raise ValueError("unknown policy implementation: %r" % name)
|
|
63
|
+
|
|
64
|
+
_implementation_name = name
|
|
65
|
+
for modname, names in _policy_names.items():
|
|
66
|
+
__import__(modname)
|
|
67
|
+
mod = sys.modules[modname]
|
|
68
|
+
for n in names:
|
|
69
|
+
setattr(mod, n, getattr(impl, n))
|
|
70
|
+
if hasattr(mod, "initialize"):
|
|
71
|
+
mod.initialize(impl)
|
|
72
|
+
|
|
73
|
+
from AccessControl.SecurityManager import setSecurityPolicy
|
|
74
|
+
policy = impl.ZopeSecurityPolicy(True, True)
|
|
75
|
+
setSecurityPolicy(policy)
|
|
76
|
+
|
|
77
|
+
_implementation_set = 1
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
# start with the default, mostly because we need something for the tests
|
|
81
|
+
_default_implementation = 'C'
|
|
82
|
+
_implementation_name = None
|
|
83
|
+
_implementation_set = 0
|
|
84
|
+
|
|
85
|
+
_policy_names = {
|
|
86
|
+
"AccessControl": ("setDefaultBehaviors",
|
|
87
|
+
),
|
|
88
|
+
"AccessControl.PermissionRole": ("_what_not_even_god_should_do",
|
|
89
|
+
"rolesForPermissionOn",
|
|
90
|
+
"PermissionRole",
|
|
91
|
+
"imPermissionRole",
|
|
92
|
+
),
|
|
93
|
+
"AccessControl.SecurityManagement": ("SecurityManager",
|
|
94
|
+
),
|
|
95
|
+
"AccessControl.SecurityManager": ("SecurityManager",
|
|
96
|
+
),
|
|
97
|
+
"AccessControl.ZopeGuards": ("aq_validate",
|
|
98
|
+
"guarded_getattr",
|
|
99
|
+
),
|
|
100
|
+
"AccessControl.ZopeSecurityPolicy": ("ZopeSecurityPolicy",
|
|
101
|
+
),
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
if CAPI:
|
|
106
|
+
setImplementation(_default_implementation)
|
|
107
|
+
else:
|
|
108
|
+
setImplementation('PYTHON')
|
|
109
|
+
|
|
110
|
+
# allow the implementation to change from the default
|
|
111
|
+
_implementation_set = 0
|
AccessControl/Owned.py
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
##############################################################################
|
|
2
|
+
#
|
|
3
|
+
# Copyright (c) 2002 Zope Foundation and Contributors.
|
|
4
|
+
#
|
|
5
|
+
# This software is subject to the provisions of the Zope Public License,
|
|
6
|
+
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
|
|
7
|
+
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
|
|
8
|
+
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
9
|
+
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
|
|
10
|
+
# FOR A PARTICULAR PURPOSE
|
|
11
|
+
#
|
|
12
|
+
##############################################################################
|
|
13
|
+
"""Support for owned objects
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
from zope.deferredimport import deprecated
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
deprecated(
|
|
20
|
+
"The functionality of AccessControl.Owned has moved to"
|
|
21
|
+
" AccessControl.owner. Please import from there."
|
|
22
|
+
" This backward compatibility shim will be removed in AccessControl"
|
|
23
|
+
" version 6.",
|
|
24
|
+
EditUnowned='AccessControl.owner:EditUnowned',
|
|
25
|
+
EmergencyUserCannotOwn='AccessControl.owner:EmergencyUserCannotOwn',
|
|
26
|
+
UnownableOwner='AccessControl.owner:UnownableOwner',
|
|
27
|
+
absattr='AccessControl.owner:absattr',
|
|
28
|
+
ownableFilter='AccessControl.owner:ownableFilter',
|
|
29
|
+
ownerInfo='AccessControl.owner:ownerInfo',
|
|
30
|
+
)
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
##############################################################################
|
|
2
|
+
#
|
|
3
|
+
# Copyright (c) 2002 Zope Foundation and Contributors.
|
|
4
|
+
#
|
|
5
|
+
# This software is subject to the provisions of the Zope Public License,
|
|
6
|
+
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
|
|
7
|
+
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
|
|
8
|
+
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
9
|
+
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
|
|
10
|
+
# FOR A PARTICULAR PURPOSE.
|
|
11
|
+
#
|
|
12
|
+
##############################################################################
|
|
13
|
+
"""Permissions
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
import re
|
|
17
|
+
|
|
18
|
+
from Acquisition import aq_base
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
_NOT_ALLOWED_CHARS = re.compile(r'[^a-zA-Z0-9_]')
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def getPermissionIdentifier(name):
|
|
25
|
+
return '_' + re.sub(_NOT_ALLOWED_CHARS, '_', name) + "_Permission"
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
# BBB
|
|
29
|
+
pname = getPermissionIdentifier
|
|
30
|
+
|
|
31
|
+
_marker = []
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class Permission:
|
|
35
|
+
# A Permission maps a named logical permission to a set
|
|
36
|
+
# of attribute names. Attribute names which appear in a
|
|
37
|
+
# permission may not appear in any other permission defined
|
|
38
|
+
# by the object.
|
|
39
|
+
|
|
40
|
+
def __init__(self, name, data, obj, default=None):
|
|
41
|
+
self.name = name
|
|
42
|
+
self._p = getPermissionIdentifier(name)
|
|
43
|
+
self.data = data
|
|
44
|
+
self.obj = aq_base(obj)
|
|
45
|
+
self.default = default
|
|
46
|
+
|
|
47
|
+
def getRoles(self, default=_marker):
|
|
48
|
+
# Return the list of role names which have been given
|
|
49
|
+
# this permission for the object in question. To do
|
|
50
|
+
# this, we try to get __roles__ from all of the object
|
|
51
|
+
# attributes that this permission represents.
|
|
52
|
+
obj = self.obj
|
|
53
|
+
name = self._p
|
|
54
|
+
if hasattr(obj, name):
|
|
55
|
+
return getattr(obj, name)
|
|
56
|
+
roles = default
|
|
57
|
+
for name in self.data:
|
|
58
|
+
if name:
|
|
59
|
+
if hasattr(obj, name):
|
|
60
|
+
attr = getattr(obj, name)
|
|
61
|
+
if getattr(attr, '__self__', None) is not None:
|
|
62
|
+
attr = attr.__self__
|
|
63
|
+
if hasattr(attr, '__dict__'):
|
|
64
|
+
attr = attr.__dict__
|
|
65
|
+
name = name + '__roles__'
|
|
66
|
+
if name in attr:
|
|
67
|
+
roles = attr[name]
|
|
68
|
+
break
|
|
69
|
+
elif hasattr(obj, '__dict__'):
|
|
70
|
+
attr = obj.__dict__
|
|
71
|
+
if '__roles__' in attr:
|
|
72
|
+
roles = attr['__roles__']
|
|
73
|
+
break
|
|
74
|
+
|
|
75
|
+
if roles:
|
|
76
|
+
try:
|
|
77
|
+
if 'Shared' not in roles:
|
|
78
|
+
return tuple(roles)
|
|
79
|
+
roles = list(roles)
|
|
80
|
+
roles.remove('Shared')
|
|
81
|
+
return roles
|
|
82
|
+
except BaseException:
|
|
83
|
+
return []
|
|
84
|
+
|
|
85
|
+
if roles is None:
|
|
86
|
+
return ['Manager', 'Anonymous']
|
|
87
|
+
if roles is _marker:
|
|
88
|
+
return ['Manager']
|
|
89
|
+
|
|
90
|
+
return roles
|
|
91
|
+
|
|
92
|
+
def setRoles(self, roles):
|
|
93
|
+
obj = self.obj
|
|
94
|
+
|
|
95
|
+
if isinstance(roles, list) and not roles:
|
|
96
|
+
if hasattr(obj, self._p):
|
|
97
|
+
delattr(obj, self._p)
|
|
98
|
+
else:
|
|
99
|
+
setattr(obj, self._p, roles)
|
|
100
|
+
|
|
101
|
+
for name in self.data:
|
|
102
|
+
if name == '':
|
|
103
|
+
attr = obj
|
|
104
|
+
else:
|
|
105
|
+
attr = getattr(obj, name)
|
|
106
|
+
try:
|
|
107
|
+
del attr.__roles__
|
|
108
|
+
except BaseException:
|
|
109
|
+
pass
|
|
110
|
+
try:
|
|
111
|
+
delattr(obj, name + '__roles__')
|
|
112
|
+
except BaseException:
|
|
113
|
+
pass
|
|
114
|
+
|
|
115
|
+
def setRole(self, role, present):
|
|
116
|
+
roles = self.getRoles()
|
|
117
|
+
if role in roles:
|
|
118
|
+
if present:
|
|
119
|
+
return
|
|
120
|
+
if isinstance(roles, list):
|
|
121
|
+
roles.remove(role)
|
|
122
|
+
else:
|
|
123
|
+
roles = list(roles)
|
|
124
|
+
roles.remove(role)
|
|
125
|
+
roles = tuple(roles)
|
|
126
|
+
elif not present:
|
|
127
|
+
return
|
|
128
|
+
else:
|
|
129
|
+
if isinstance(roles, list):
|
|
130
|
+
roles.append(role)
|
|
131
|
+
else:
|
|
132
|
+
roles = roles + (role, )
|
|
133
|
+
self.setRoles(roles)
|
|
134
|
+
|
|
135
|
+
def __len__(self):
|
|
136
|
+
return 1
|
|
137
|
+
|
|
138
|
+
def __str__(self):
|
|
139
|
+
return self.name
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
_registeredPermissions = {}
|
|
143
|
+
_ac_permissions = ()
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
def getPermissions():
|
|
147
|
+
return _ac_permissions
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
def addPermission(perm, default_roles=('Manager', )):
|
|
151
|
+
if perm in _registeredPermissions:
|
|
152
|
+
return
|
|
153
|
+
|
|
154
|
+
entry = ((perm, (), default_roles), )
|
|
155
|
+
global _ac_permissions
|
|
156
|
+
_ac_permissions = _ac_permissions + entry
|
|
157
|
+
_registeredPermissions[perm] = 1
|
|
158
|
+
mangled = getPermissionIdentifier(perm)
|
|
159
|
+
if not hasattr(ApplicationDefaultPermissions, mangled):
|
|
160
|
+
setattr(ApplicationDefaultPermissions, mangled, default_roles)
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
def registerPermissions(permissions, defaultDefault=('Manager', )):
|
|
164
|
+
"""Register an __ac_permissions__ sequence.
|
|
165
|
+
"""
|
|
166
|
+
for setting in permissions:
|
|
167
|
+
if setting[0] in _registeredPermissions:
|
|
168
|
+
continue
|
|
169
|
+
if len(setting) == 2:
|
|
170
|
+
perm, methods = setting
|
|
171
|
+
default = defaultDefault
|
|
172
|
+
else:
|
|
173
|
+
perm, methods, default = setting
|
|
174
|
+
addPermission(perm, default)
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
class ApplicationDefaultPermissions:
|
|
178
|
+
_View_Permission = ('Manager', 'Anonymous')
|
|
179
|
+
_Access_contents_information_Permission = ('Manager', 'Anonymous')
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
##############################################################################
|
|
2
|
+
#
|
|
3
|
+
# Copyright (c) 2002 Zope Foundation and Contributors.
|
|
4
|
+
#
|
|
5
|
+
# This software is subject to the provisions of the Zope Public License,
|
|
6
|
+
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
|
|
7
|
+
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
|
|
8
|
+
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
9
|
+
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
|
|
10
|
+
# FOR A PARTICULAR PURPOSE
|
|
11
|
+
#
|
|
12
|
+
##############################################################################
|
|
13
|
+
"""Permission Mapping
|
|
14
|
+
|
|
15
|
+
Sometimes, we need an object's permissions to be remapped to other permissions
|
|
16
|
+
when the object is used in special ways. This is rather hard, since we
|
|
17
|
+
need the object's ordinary permissions intact so we can manage it.
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
from html import escape
|
|
21
|
+
|
|
22
|
+
from Acquisition import ImplicitAcquisitionWrapper
|
|
23
|
+
from ExtensionClass import Base
|
|
24
|
+
from zope.interface import implementer
|
|
25
|
+
|
|
26
|
+
from AccessControl.class_init import InitializeClass
|
|
27
|
+
from AccessControl.interfaces import IPermissionMappingSupport
|
|
28
|
+
from AccessControl.owner import UnownableOwner
|
|
29
|
+
from AccessControl.Permission import getPermissionIdentifier
|
|
30
|
+
from AccessControl.requestmethod import requestmethod
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
@implementer(IPermissionMappingSupport)
|
|
34
|
+
class RoleManager:
|
|
35
|
+
|
|
36
|
+
# XXX: No security declarations?
|
|
37
|
+
|
|
38
|
+
def manage_getPermissionMapping(self):
|
|
39
|
+
"""Return the permission mapping for the object
|
|
40
|
+
|
|
41
|
+
This is a list of dictionaries with:
|
|
42
|
+
|
|
43
|
+
permission_name -- The name of the native object permission
|
|
44
|
+
|
|
45
|
+
class_permission -- The class permission the permission is
|
|
46
|
+
mapped to.
|
|
47
|
+
"""
|
|
48
|
+
wrapper = getattr(self, '_permissionMapper', None)
|
|
49
|
+
if wrapper is None:
|
|
50
|
+
wrapper = PM()
|
|
51
|
+
|
|
52
|
+
perms = {}
|
|
53
|
+
for p in self.possible_permissions():
|
|
54
|
+
perms[getPermissionIdentifier(p)] = p
|
|
55
|
+
|
|
56
|
+
r = []
|
|
57
|
+
a = r.append
|
|
58
|
+
for ac_perms in self.ac_inherited_permissions(1):
|
|
59
|
+
p = perms.get(getPermissionMapping(ac_perms[0], wrapper), '')
|
|
60
|
+
a({'permission_name': ac_perms[0], 'class_permission': p})
|
|
61
|
+
return r
|
|
62
|
+
|
|
63
|
+
@requestmethod('POST')
|
|
64
|
+
def manage_setPermissionMapping(self,
|
|
65
|
+
permission_names=[],
|
|
66
|
+
class_permissions=[],
|
|
67
|
+
REQUEST=None):
|
|
68
|
+
"""Change the permission mapping
|
|
69
|
+
"""
|
|
70
|
+
wrapper = getattr(self, '_permissionMapper', None)
|
|
71
|
+
if wrapper is None:
|
|
72
|
+
wrapper = PM()
|
|
73
|
+
|
|
74
|
+
perms = self.possible_permissions()
|
|
75
|
+
for i in range(len(permission_names)):
|
|
76
|
+
name = permission_names[i]
|
|
77
|
+
p = class_permissions[i]
|
|
78
|
+
if p and (p not in perms):
|
|
79
|
+
__traceback_info__ = perms, p, i
|
|
80
|
+
raise ValueError(
|
|
81
|
+
"""Attempted to map a permission to a permission, %s,
|
|
82
|
+
that is not valid. This should never happen. (Waaa).
|
|
83
|
+
""" % escape(p))
|
|
84
|
+
setPermissionMapping(name, wrapper, p)
|
|
85
|
+
|
|
86
|
+
self._permissionMapper = wrapper
|
|
87
|
+
|
|
88
|
+
if REQUEST is not None:
|
|
89
|
+
return self.manage_access(
|
|
90
|
+
REQUEST,
|
|
91
|
+
manage_tabs_message='The permission mapping has been updated')
|
|
92
|
+
|
|
93
|
+
def _isBeingUsedAsAMethod(self, REQUEST=None, wannaBe=0):
|
|
94
|
+
try:
|
|
95
|
+
if hasattr(self, 'aq_self'):
|
|
96
|
+
r = self.aq_acquire('_isBeingUsedAsAMethod_')
|
|
97
|
+
else:
|
|
98
|
+
r = self._isBeingUsedAsAMethod_
|
|
99
|
+
except BaseException:
|
|
100
|
+
r = 0
|
|
101
|
+
|
|
102
|
+
if REQUEST is not None:
|
|
103
|
+
if not r != (not wannaBe):
|
|
104
|
+
REQUEST.response.notFoundError()
|
|
105
|
+
|
|
106
|
+
return r
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
InitializeClass(RoleManager)
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
def getPermissionMapping(name, obj, st=str):
|
|
113
|
+
obj = getattr(obj, 'aq_base', obj)
|
|
114
|
+
name = getPermissionIdentifier(name)
|
|
115
|
+
r = getattr(obj, name, '')
|
|
116
|
+
if not isinstance(r, st):
|
|
117
|
+
r = ''
|
|
118
|
+
return r
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
def setPermissionMapping(name, obj, v):
|
|
122
|
+
name = getPermissionIdentifier(name)
|
|
123
|
+
if v:
|
|
124
|
+
setattr(obj, name, getPermissionIdentifier(v))
|
|
125
|
+
elif name in obj.__dict__:
|
|
126
|
+
delattr(obj, name)
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
class PM(Base):
|
|
130
|
+
_owner = UnownableOwner
|
|
131
|
+
|
|
132
|
+
_View_Permission = '_View_Permission'
|
|
133
|
+
_is_wrapperish = 1
|
|
134
|
+
|
|
135
|
+
def __getattr__(self, name):
|
|
136
|
+
# We want to make sure that any non-explicitly set methods are
|
|
137
|
+
# private!
|
|
138
|
+
if name.startswith('_') and name.endswith("_Permission"):
|
|
139
|
+
return ''
|
|
140
|
+
raise AttributeError(escape(name))
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
PermissionMapper = PM
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
def aqwrap(object, wrapper, parent):
|
|
147
|
+
r = Rewrapper()
|
|
148
|
+
r._ugh = wrapper, object, parent
|
|
149
|
+
return r
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
class Rewrapper(Base):
|
|
153
|
+
def __of__(self, parent):
|
|
154
|
+
w, m, p = self._ugh
|
|
155
|
+
return m.__of__(ImplicitAcquisitionWrapper(w, parent))
|
|
156
|
+
|
|
157
|
+
def __getattr__(self, name):
|
|
158
|
+
w, m, parent = self._ugh
|
|
159
|
+
self = m.__of__(ImplicitAcquisitionWrapper(w, parent))
|
|
160
|
+
return getattr(self, name)
|
|
161
|
+
|
|
162
|
+
def __call__(self, *args, **kw):
|
|
163
|
+
w, m, parent = self._ugh
|
|
164
|
+
self = m.__of__(ImplicitAcquisitionWrapper(w, parent))
|
|
165
|
+
return self(*args, **kw)
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
##############################################################################
|
|
2
|
+
#
|
|
3
|
+
# Copyright (c) 2002 Zope Foundation and Contributors.
|
|
4
|
+
#
|
|
5
|
+
# This software is subject to the provisions of the Zope Public License,
|
|
6
|
+
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
|
|
7
|
+
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
|
|
8
|
+
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
9
|
+
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
|
|
10
|
+
# FOR A PARTICULAR PURPOSE
|
|
11
|
+
#
|
|
12
|
+
##############################################################################
|
|
13
|
+
'''Objects that implement Permission-based roles.
|
|
14
|
+
'''
|
|
15
|
+
|
|
16
|
+
# The following names are inserted by AccessControl.Implementation:
|
|
17
|
+
#
|
|
18
|
+
# rolesForPermissionOn, PermissionRole, imPermissionRole,
|
|
19
|
+
# _what_not_even_god_should_do
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
##############################################################################
|
|
2
|
+
#
|
|
3
|
+
# Copyright (c) 2002 Zope Foundation and Contributors.
|
|
4
|
+
#
|
|
5
|
+
# This software is subject to the provisions of the Zope Public License,
|
|
6
|
+
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
|
|
7
|
+
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
|
|
8
|
+
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
9
|
+
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
|
|
10
|
+
# FOR A PARTICULAR PURPOSE
|
|
11
|
+
#
|
|
12
|
+
##############################################################################
|
|
13
|
+
"""Constant definitions for built-in Zope permissions
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
access_contents_information = 'Access contents information'
|
|
17
|
+
add_database_methods = 'Add Database Methods'
|
|
18
|
+
add_documents_images_and_files = 'Add Documents, Images, and Files'
|
|
19
|
+
add_external_methods = 'Add External Methods'
|
|
20
|
+
add_folders = 'Add Folders'
|
|
21
|
+
add_mailhost_objects = 'Add MailHost objects'
|
|
22
|
+
add_page_templates = 'Add Page Templates'
|
|
23
|
+
add_python_scripts = 'Add Python Scripts'
|
|
24
|
+
add_user_folders = 'Add User Folders'
|
|
25
|
+
add_vocabularies = 'Add Vocabularies'
|
|
26
|
+
add_z_gadfly_database_connections = 'Add Z Gadfly Database Connections'
|
|
27
|
+
add_zcatalogs = 'Add ZCatalogs'
|
|
28
|
+
add_zope_tutorials = 'Add Zope Tutorials'
|
|
29
|
+
change_database_connections = 'Change Database Connections'
|
|
30
|
+
change_database_methods = 'Change Database Methods'
|
|
31
|
+
change_external_methods = 'Change External Methods'
|
|
32
|
+
change_images_and_files = 'Change Images and Files'
|
|
33
|
+
change_python_scripts = 'Change Python Scripts'
|
|
34
|
+
change_configuration = 'Change configuration'
|
|
35
|
+
change_page_templates = 'Change Page Templates'
|
|
36
|
+
change_permissions = 'Change permissions'
|
|
37
|
+
change_proxy_roles = 'Change proxy roles'
|
|
38
|
+
copy_or_move = 'Copy or Move'
|
|
39
|
+
create_class_instances = 'Create class instances'
|
|
40
|
+
define_permissions = 'Define permissions'
|
|
41
|
+
delete_objects = 'Delete objects'
|
|
42
|
+
edit_factories = 'Edit Factories'
|
|
43
|
+
ftp_access = 'FTP access'
|
|
44
|
+
import_export_objects = 'Import/Export objects'
|
|
45
|
+
manage_vocabulary = 'Manage Vocabulary'
|
|
46
|
+
manage_zcatalog_entries = 'Manage ZCatalog Entries'
|
|
47
|
+
manage_zcatalog_indexes = 'Manage ZCatalogIndex Entries'
|
|
48
|
+
manage_properties = 'Manage properties'
|
|
49
|
+
manage_users = 'Manage users'
|
|
50
|
+
open_close_database_connection = 'Open/Close Database Connection'
|
|
51
|
+
open_close_database_connections = 'Open/Close Database Connections'
|
|
52
|
+
query_vocabulary = 'Query Vocabulary'
|
|
53
|
+
search_zcatalog = 'Search ZCatalog'
|
|
54
|
+
take_ownership = 'Take ownership'
|
|
55
|
+
test_database_connections = 'Test Database Connections'
|
|
56
|
+
undo_changes = 'Undo changes'
|
|
57
|
+
use_database_methods = 'Use Database Methods'
|
|
58
|
+
use_factories = 'Use Factories'
|
|
59
|
+
use_mailhost_services = 'Use mailhost services'
|
|
60
|
+
view = 'View'
|
|
61
|
+
view_management_screens = 'View management screens'
|
|
62
|
+
webdav_access = 'WebDAV access'
|
|
63
|
+
webdav_lock_items = 'WebDAV Lock items'
|
|
64
|
+
webdav_manage_locks = 'Manage WebDAV Locks'
|
|
65
|
+
webdav_unlock_items = 'WebDAV Unlock items'
|
AccessControl/Role.py
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
##############################################################################
|
|
2
|
+
#
|
|
3
|
+
# Copyright (c) 2002 Zope Foundation and Contributors.
|
|
4
|
+
#
|
|
5
|
+
# This software is subject to the provisions of the Zope Public License,
|
|
6
|
+
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
|
|
7
|
+
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
|
|
8
|
+
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
9
|
+
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
|
|
10
|
+
# FOR A PARTICULAR PURPOSE
|
|
11
|
+
#
|
|
12
|
+
##############################################################################
|
|
13
|
+
"""Access control support
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
from zope.deferredimport import deprecated
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
deprecated(
|
|
20
|
+
"The functionality of AccessControl.Role has moved to"
|
|
21
|
+
" AccessControl.rolemanager. Please import from there."
|
|
22
|
+
" This backward compatibility shim will be removed in AccessControl"
|
|
23
|
+
" version 6.",
|
|
24
|
+
DEFAULTMAXLISTUSERS='AccessControl.rolemanager:DEFAULTMAXLISTUSERS',
|
|
25
|
+
_isBeingUsedAsAMethod='AccessControl.rolemanager:_isBeingUsedAsAMethod',
|
|
26
|
+
_isNotBeingUsedAsAMethod='AccessControl.rolemanager:_isNotBeingUsedAsAMethod', # noqa
|
|
27
|
+
class_attrs='AccessControl.rolemanager:class_attrs',
|
|
28
|
+
class_dict='AccessControl.rolemanager:class_dict',
|
|
29
|
+
classattr='AccessControl.rolemanager:classattr',
|
|
30
|
+
gather_permissions='AccessControl.rolemanager:gather_permissions',
|
|
31
|
+
instance_attrs='AccessControl.rolemanager:instance_attrs',
|
|
32
|
+
instance_dict='AccessControl.rolemanager:instance_dict',
|
|
33
|
+
reqattr='AccessControl.rolemanager:reqattr',
|
|
34
|
+
)
|