[Zodb-checkins] CVS: ZODB3/ZEO/zrpc - connection.py:1.47.2.1

Jeremy Hylton jeremy at zope.com
Wed May 28 15:36:28 EDT 2003


Update of /cvs-repository/ZODB3/ZEO/zrpc
In directory cvs.zope.org:/tmp/cvs-serv5189/ZEO/zrpc

Modified Files:
      Tag: ZODB3-auth-branch
	connection.py 
Log Message:
Big refactoring of authentication mechanism.

Add mac to the smac layer.
Add explicit realm for use by client and server.
Add authentication to the ZEO schema components.
Add session key generation to digest authentication.

Add a new zeopasswd.py script that isn't quite done.
Move plaintext authentication to the tests directory; it isn't
supposed to be used for real.


=== ZODB3/ZEO/zrpc/connection.py 1.47 => 1.47.2.1 ===
--- ZODB3/ZEO/zrpc/connection.py:1.47	Thu Apr 24 18:04:27 2003
+++ ZODB3/ZEO/zrpc/connection.py	Wed May 28 14:36:28 2003
@@ -114,6 +114,7 @@
 
     __super_init = smac.SizedMessageAsyncConnection.__init__
     __super_close = smac.SizedMessageAsyncConnection.close
+    __super_setSessionKey = smac.SizedMessageAsyncConnection.setSessionKey
 
     # Protocol variables:
     #
@@ -152,12 +153,17 @@
         self.trigger = None
         self._prepare_async()
         self._map = {self._fileno: self}
-        # __msgid_lock guards access to msgid
+        # msgid_lock guards access to msgid
         self.msgid_lock = threading.Lock()
-        # __replies_cond is used to block when a synchronous call is
+        # replies_cond is used to block when a synchronous call is
         # waiting for a response
         self.replies_cond = threading.Condition()
         self.replies = {}
+        # waiting_for_reply is used internally to indicate whether
+        # a call is in progress.  setting a session key is deferred
+        # until after the call returns.
+        self.waiting_for_reply = False
+        self.delay_sesskey = None
         self.register_object(obj)
         self.handshake()
 
@@ -249,7 +255,11 @@
 
         meth = getattr(self.obj, name)
         try:
-            ret = meth(*args)
+            self.waiting_for_reply = True
+            try:
+                ret = meth(*args)
+            finally:
+                self.waiting_for_reply = False
         except (SystemExit, KeyboardInterrupt):
             raise
         except Exception, msg:
@@ -271,6 +281,10 @@
             else:
                 self.send_reply(msgid, ret)
 
+        if self.delay_sesskey:
+            self.__super_setSessionKey(self.delay_sesskey)
+            self.delay_sesskey = None
+
     def handle_error(self):
         if sys.exc_info()[0] == SystemExit:
             raise sys.exc_info()
@@ -317,6 +331,12 @@
             msg = self.marshal.encode(msgid, 0, REPLY, (ZRPCError, err))
         self.message_output(msg)
         self.poll()
+
+    def setSessionKey(self, key):
+        if self.waiting_for_reply:
+            self.delay_sesskey = key
+        else:
+            self.__super_setSessionKey(key)
 
     # The next two public methods (call and callAsync) are used by
     # clients to invoke methods on remote objects




More information about the Zodb-checkins mailing list