[Zope-Checkins] CVS: ZODB3/ZEO - StorageServer.py:1.92.10.7

Jeremy Hylton jeremy@zope.com
Thu, 29 May 2003 17:39:31 -0400


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

Modified Files:
      Tag: ZODB3-auth-branch
	StorageServer.py 
Log Message:
Change the StorageServer to be explicitly told what the realm is.

If the realm passed to the server doesn't match the realm in the
password database, complain.  Fix the tests to work with this new
scheme.



=== ZODB3/ZEO/StorageServer.py 1.92.10.6 => 1.92.10.7 ===
--- ZODB3/ZEO/StorageServer.py:1.92.10.6	Thu May 29 17:30:10 2003
+++ ZODB3/ZEO/StorageServer.py	Thu May 29 17:39:30 2003
@@ -69,7 +69,7 @@
     # should override.
     extensions = []
 
-    def __init__(self, server, read_only=0, do_auth=0):
+    def __init__(self, server, read_only=0, auth_realm=None):
         self.server = server
         # timeout and stats will be initialized in register()
         self.timeout = None
@@ -84,14 +84,14 @@
         self.verifying = 0
         self.log_label = _label
         self.authenticated = 0
-        self.do_auth = do_auth
+        self.auth_realm = auth_realm
         # The authentication protocol may define extra methods.
         self._extensions = {}
         for func in self.extensions:
             self._extensions[func.func_name] = None
         
     def finish_auth(self, authenticated):
-        if not self.do_auth:
+        if not self.auth_realm:
             return 1
         self.authenticated = authenticated
         return authenticated
@@ -195,7 +195,7 @@
         For authenticated storages this method will be called by the client
         immediately after authentication is finished.
         """
-        if self.do_auth and not self.authenticated:
+        if self.auth_realm and not self.authenticated:
             raise AuthError, "Client was never authenticated with server!"
 
         if self.storage is not None:
@@ -738,6 +738,11 @@
         # Database that would contain the same info, and also avoiding any
         # possibly synchronization issues between them.
         self.database = db_class(self.auth_filename)
+        if self.database.realm != self.auth_realm:
+            raise ValueError("password database realm %r "
+                             "does not match storage realm %r"
+                             % (self.database.realm, self.auth_realm))
+
         
     def new_connection(self, sock, addr):
         """Internal: factory to create a new connection.
@@ -747,7 +752,8 @@
         connection.
         """
         if self.auth_protocol and self.database:
-            zstorage = self.ZEOStorageClass(self, self.read_only, do_auth=1)
+            zstorage = self.ZEOStorageClass(self, self.read_only,
+                                            auth_realm=self.auth_realm)
             zstorage.set_database(self.database)
         else:
             zstorage = self.ZEOStorageClass(self, self.read_only)