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.
Files changed (71) hide show
  1. AccessControl/AuthEncoding.py +48 -0
  2. AccessControl/ImplC.py +39 -0
  3. AccessControl/ImplPython.py +914 -0
  4. AccessControl/Implementation.py +111 -0
  5. AccessControl/Owned.py +30 -0
  6. AccessControl/Permission.py +179 -0
  7. AccessControl/PermissionMapping.py +165 -0
  8. AccessControl/PermissionRole.py +19 -0
  9. AccessControl/Permissions.py +65 -0
  10. AccessControl/Role.py +34 -0
  11. AccessControl/SecurityInfo.py +502 -0
  12. AccessControl/SecurityManagement.py +84 -0
  13. AccessControl/SecurityManager.py +30 -0
  14. AccessControl/SimpleObjectPolicies.py +151 -0
  15. AccessControl/SpecialUsers.py +25 -0
  16. AccessControl/User.py +54 -0
  17. AccessControl/ZopeGuards.py +712 -0
  18. AccessControl/ZopeSecurityPolicy.py +61 -0
  19. AccessControl/__init__.py +55 -0
  20. AccessControl/_compat.h +18 -0
  21. AccessControl/cAccessControl.c +2526 -0
  22. AccessControl/cAccessControl.cp315-win_amd64.pyd +0 -0
  23. AccessControl/class_init.py +94 -0
  24. AccessControl/configure.zcml +5 -0
  25. AccessControl/frozen.py +57 -0
  26. AccessControl/interfaces.py +390 -0
  27. AccessControl/logger_wrapper.py +8 -0
  28. AccessControl/meta.zcml +52 -0
  29. AccessControl/metaconfigure.py +61 -0
  30. AccessControl/owner.py +288 -0
  31. AccessControl/permissions.zcml +100 -0
  32. AccessControl/requestmethod.py +96 -0
  33. AccessControl/rolemanager.py +490 -0
  34. AccessControl/safe_formatter.py +86 -0
  35. AccessControl/security.py +203 -0
  36. AccessControl/tainted.py +195 -0
  37. AccessControl/tests/__init__.py +0 -0
  38. AccessControl/tests/actual_python.py +260 -0
  39. AccessControl/tests/mixed_module/__init__.py +9 -0
  40. AccessControl/tests/mixed_module/submodule/__init__.py +5 -0
  41. AccessControl/tests/private_module/__init__.py +5 -0
  42. AccessControl/tests/private_module/submodule/__init__.py +5 -0
  43. AccessControl/tests/public_module/__init__.py +11 -0
  44. AccessControl/tests/public_module/submodule/__init__.py +5 -0
  45. AccessControl/tests/testClassSecurityInfo.py +192 -0
  46. AccessControl/tests/testImplementation.py +65 -0
  47. AccessControl/tests/testModuleSecurity.py +335 -0
  48. AccessControl/tests/testPermissionMapping.py +12 -0
  49. AccessControl/tests/testPermissionRole.py +170 -0
  50. AccessControl/tests/testSecurityManager.py +264 -0
  51. AccessControl/tests/testZCML.py +489 -0
  52. AccessControl/tests/testZopeGuards.py +1086 -0
  53. AccessControl/tests/testZopeSecurityPolicy.py +799 -0
  54. AccessControl/tests/test_frozen.py +124 -0
  55. AccessControl/tests/test_owner.py +289 -0
  56. AccessControl/tests/test_requestmethod.py +138 -0
  57. AccessControl/tests/test_rolemanager.py +137 -0
  58. AccessControl/tests/test_safe_formatter.py +226 -0
  59. AccessControl/tests/test_safeiter.py +59 -0
  60. AccessControl/tests/test_tainted.py +320 -0
  61. AccessControl/tests/test_userfolder.py +198 -0
  62. AccessControl/tests/test_users.py +666 -0
  63. AccessControl/unauthorized.py +38 -0
  64. AccessControl/userfolder.py +432 -0
  65. AccessControl/users.py +502 -0
  66. accesscontrol-7.6.dist-info/METADATA +474 -0
  67. accesscontrol-7.6.dist-info/RECORD +71 -0
  68. accesscontrol-7.6.dist-info/WHEEL +5 -0
  69. accesscontrol-7.6.dist-info/entry_points.txt +2 -0
  70. accesscontrol-7.6.dist-info/licenses/LICENSE.txt +44 -0
  71. accesscontrol-7.6.dist-info/top_level.txt +1 -0
@@ -0,0 +1,151 @@
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
+ '''Collect rules for access to objects that don\'t have roles.
14
+
15
+ The rules are expressed as a mapping from type -> assertion
16
+
17
+ An assertion can be:
18
+
19
+ - A dict
20
+
21
+ - A callable
22
+
23
+ - Something with a truth value
24
+
25
+ If the assertion is a callable, then it will be called with
26
+ a name being accessed and the name used. Its return value is ignored,
27
+ but in may veto an access by raising an exception.
28
+
29
+ If the assertion is a dictionary, then the keys are attribute names.
30
+ The values may be callables or objects with boolean values. If a value
31
+ is callable, it will be called with the object we are accessing an
32
+ attribute of and the attribute name. It should return an attribute
33
+ value. Callables are often used to returned guarded versions of
34
+ methods. Otherwise, accesses are allowed if values in this dictionary
35
+ are true and disallowed if the values are false or if an item for an
36
+ attribute name is not present.
37
+
38
+ If the assertion is not a dict and is not callable, then access to
39
+ unprotected attributes is allowed if the assertion is true, and
40
+ disallowed otherwise.
41
+
42
+ XXX This descrition doesn't actually match what's done in ZopeGuards
43
+ or in ZopeSecurityPolicy. :(
44
+ '''
45
+
46
+ from contextlib import contextmanager
47
+
48
+ from BTrees.IIBTree import IIBTree
49
+ from BTrees.IIBTree import IIBucket
50
+ from BTrees.IIBTree import IISet
51
+ from BTrees.IOBTree import IOBTree
52
+ from BTrees.IOBTree import IOBucket
53
+ from BTrees.IOBTree import IOSet
54
+ from BTrees.OIBTree import OIBTree
55
+ from BTrees.OIBTree import OIBucket
56
+ from BTrees.OIBTree import OISet
57
+ #
58
+ # WAAAA!
59
+ #
60
+ from BTrees.OOBTree import OOBTree
61
+ from BTrees.OOBTree import OOBucket
62
+ from BTrees.OOBTree import OOSet
63
+
64
+ from AccessControl.frozen import FreezableDict
65
+
66
+
67
+ _noroles = [] # this is imported in various places
68
+ _marker = object()
69
+
70
+ # ContainerAssertions are used by cAccessControl to check access to
71
+ # attributes of container types, like dict, list, or string.
72
+ # ContainerAssertions maps types to a either a dict, a function, or a
73
+ # simple boolean value. When guarded_getattr checks the type of its
74
+ # first argument against ContainerAssertions, and invokes checking
75
+ # logic depending on what value it finds.
76
+
77
+ # If the value for a type is:
78
+ # - a boolean value:
79
+ # - the value determines whether access is allowed
80
+ # - a function (or callable):
81
+ # - The function is called with the name of the attribute and
82
+ # the actual attribute value, then the value is returned.
83
+ # The function can raise an exception.
84
+ # - a dict:
85
+ # - The dict maps attribute names to boolean values or functions.
86
+ # The boolean values behave as above, but the functions do not.
87
+ # The value returned for attribute access is the result of
88
+ # calling the function with the object and the attribute name.
89
+ # Changes are refused once security declarations are frozen.
90
+ ContainerAssertions = FreezableDict({
91
+ type(()): 1,
92
+ bytes: 1,
93
+ str: 1,
94
+ range: 1,
95
+ })
96
+
97
+ Containers = ContainerAssertions.get
98
+
99
+
100
+ def allow_type(Type, allowed=1):
101
+ """Allow a type and all of its methods and attributes to be used from
102
+ restricted code. The argument Type must be a type."""
103
+ if not isinstance(Type, type):
104
+ raise ValueError("%r is not a type" % Type)
105
+ if hasattr(Type, '__roles__'):
106
+ raise ValueError("%r handles its own security" % Type)
107
+ if not (isinstance(allowed, int) or isinstance(allowed, dict)):
108
+ raise ValueError("The 'allowed' argument must be an int or dict.")
109
+ ContainerAssertions[Type] = allowed
110
+
111
+
112
+ allow_type.__roles__ = () # Only accessible from trusted code
113
+
114
+
115
+ for tree_type, has_values in [
116
+ (OOBTree, 1),
117
+ (OOBucket, 1),
118
+ (OOSet, 0),
119
+ (OIBTree, 1),
120
+ (OIBucket, 1),
121
+ (OISet, 0),
122
+ (IOBTree, 1),
123
+ (IOBucket, 1),
124
+ (IOSet, 0),
125
+ (IIBTree, 1),
126
+ (IIBucket, 1),
127
+ (IISet, 0),
128
+ ]:
129
+ tree = tree_type()
130
+ keys = tree.keys()
131
+
132
+ if not isinstance(keys, list): # lists have their own declarations
133
+ allow_type(type(keys))
134
+
135
+ if has_values:
136
+ assert isinstance(keys, type(tree.values()))
137
+ assert isinstance(keys, type(tree.items()))
138
+
139
+
140
+ @contextmanager
141
+ def override_containers(type_, assertions):
142
+ """Temporarily override the container assertions."""
143
+ orig_container = Containers(type_, _marker)
144
+ ContainerAssertions[type_] = assertions
145
+ try:
146
+ yield
147
+ finally:
148
+ if orig_container is _marker:
149
+ del ContainerAssertions[type_]
150
+ else:
151
+ ContainerAssertions[type_] = orig_container
@@ -0,0 +1,25 @@
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
+ """Place to find special users
14
+
15
+ This is needed to avoid a circular import problem. The 'real' values
16
+ are stored here by the AccessControl.users module as part of its
17
+ initialization.
18
+ """
19
+
20
+ nobody = None
21
+ system = None
22
+ emergency_user = None
23
+
24
+ # Note: use of the 'super' name is deprecated.
25
+ super = None
AccessControl/User.py ADDED
@@ -0,0 +1,54 @@
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 package.
14
+ """
15
+
16
+ from zope.deferredimport import deprecated
17
+
18
+
19
+ deprecated(
20
+ "The functionality of AccessControl.User has moved to"
21
+ " AccessControl.users. Please import from there."
22
+ " This backward compatibility shim will be removed in AccessControl"
23
+ " version 6.",
24
+ BasicUser='AccessControl.users:BasicUser',
25
+ NullUnrestrictedUser='AccessControl.users:NullUnrestrictedUser',
26
+ SimpleUser='AccessControl.users:SimpleUser',
27
+ SpecialUser='AccessControl.users:SpecialUser',
28
+ Super='AccessControl.users:UnrestrictedUser',
29
+ UnrestrictedUser='AccessControl.users:UnrestrictedUser',
30
+ User='AccessControl.users:User',
31
+ _remote_user_mode='AccessControl.users:_remote_user_mode',
32
+ absattr='AccessControl.users:absattr',
33
+ addr_match='AccessControl.users:addr_match',
34
+ domainSpecMatch='AccessControl.users:domainSpecMatch',
35
+ emergency_user='AccessControl.users:emergency_user',
36
+ host_match='AccessControl.users:host_match',
37
+ nobody='AccessControl.users:nobody',
38
+ readUserAccessFile='AccessControl.users:readUserAccessFile',
39
+ reqattr='AccessControl.users:reqattr',
40
+ rolejoin='AccessControl.users:rolejoin',
41
+ system='AccessControl.users:system',
42
+ )
43
+
44
+ deprecated(
45
+ "The standard Zope user folder implementation has moved to"
46
+ " OFS.userfolder. Please depend on Zope and import from "
47
+ " OFS.userfolder or use the new minimal "
48
+ " user folder classes from AccessControl.userfolder."
49
+ " This backward compatibility shim will be removed in AccessControl"
50
+ " version 6.",
51
+ BasicUserFolder='OFS.userfolder:BasicUserFolder',
52
+ manage_addUserFolder='OFS.userfolder:manage_addUserFolder',
53
+ UserFolder='OFS.userfolder:UserFolder',
54
+ )