[Zope-Checkins] CVS: Zope/lib/python/Shared/DC/Scripts - Bindings.py:1.9.68.2

Brian Lloyd brian at zope.com
Wed Jan 21 13:51:34 EST 2004


Update of /cvs-repository/Zope/lib/python/Shared/DC/Scripts
In directory cvs.zope.org:/tmp/cvs-serv17944/lib/python/Shared/DC/Scripts

Modified Files:
      Tag: Zope-2_7-branch
	Bindings.py 
Log Message:
merge binding fixes


=== Zope/lib/python/Shared/DC/Scripts/Bindings.py 1.9.68.1 => 1.9.68.2 ===
--- Zope/lib/python/Shared/DC/Scripts/Bindings.py:1.9.68.1	Thu Jan  8 18:33:57 2004
+++ Zope/lib/python/Shared/DC/Scripts/Bindings.py	Wed Jan 21 13:51:03 2004
@@ -142,6 +142,39 @@
         return self._generateCodeBlock(text, assigned_names)
 
 
+from AccessControl.unauthorized import Unauthorized
+
+class UnauthorizedBinding:
+    """Explanation: as of Zope 2.6.3 a security hole was closed - no
+       security check was happening when 'context' and 'container'
+       were bound to a script. Adding the check broke lots of sites
+       where existing scripts had the container binding but the users
+       of the scripts didn't have access to the container (e.g. workflow
+       scripts). This meant getting unauthorized even if the container
+       binding wasn't used in the script.
+
+       Now, instead of raising unauthorized at binding time, we bind
+       to an UnauthorizedBinding that will allow the script to run if
+       it doesn't actually use the binding, but will raise a meaningful
+       unauthorized error if the binding is accessed. This makes the
+       backward compatibility problem less painful because only those
+       actually using the container binding (for ex. workflow scripts)
+       need to take explicit action to fix existing sites."""
+
+    def __init__(self, name):
+        self._name = name
+
+    __allow_access_to_unprotected_subobjects__ = 1
+
+    def __getattr__(self, name, default=None):
+        name = self.__dict__['_name']
+        raise Unauthorized('Not authorized to access binding: %s' % name)
+
+    def __getitem__(self, key, default=None):
+        name = self.__dict__['_name']
+        raise Unauthorized('Not authorized to access binding: %s' % name)
+
+
 class Bindings:
 
     __ac_permissions__ = (




More information about the Zope-Checkins mailing list