Using credentials with ZEO 5 -- possible bug in ZEOStorage
Bill Janssen <[email protected]>
| Newsgroups | gmane.comp.web.zope.zodb |
|---|---|
| Message-ID | <[email protected]> |
I've been tracing calls through ZEO 5 again. My setup is that I'm running
a big ZEO server, which services multiple users, each of which may have
access to multiple storages. When a user creates a ClientStorage, they
specify which storage they want to access, presumably via the "storage"
parameter to ClientStorage.__init__(), and pass some credentials which are
used to authenticate their identity (which in turn is used to authorize
their access to the specified storage). I see that the credentials passed
to ClientStorage are then passed through to the server as part of the
"register" call:
credentials = (self.credentials,) if self.credentials else ()
try:
try:
server_tid = yield self.fut(
'register', self.storage_key,
self.read_only if self.read_only is not Fallback else
False,
*credentials)
except ZODB.POSException.ReadOnlyError:
if self.read_only is Fallback:
self.read_only = True
server_tid = yield self.fut(
'register', self.storage_key, True, *credentials)
else:
raise
else:
if self.read_only is Fallback:
self.read_only = False
except Exception as exc:
self.client.register_failed(self, exc)
else:
self.client.registered(self, server_tid)
On the server side, the "register" method in ZEOStorage looks like this:
def register(self, storage_id, read_only):
"""Select the storage that this client will use
This method must be the first one called by the client.
For authenticated storages this method will be called by the client
immediately after authentication is finished.
"""
If credentials are passed, won't this error out because of too many
parameters?
So presumably I need to write a subtype of ZEOStorage with a version of
"register" which will accept the credentials and validate them -- a
before-method. But then I need to arrange for that subtype to be the class
that's instantiated. To do that, I need to subclass StorageServer and
override create_client_handle. Or, subclass Acceptor (from
asyncio/server.py), and override the "factory()" method -- but then I'd
have to arrange for my subclass to be used, and I don't see a clean way of
doing that except to replace "create_server" in runzeo.py. Which I'd have
to do anyway if I subclass StorageServer.
Some questions:
1. StorageServer takes a dict of storages, which are FileStorage
instances. How many is too many in this case? What if I have thousands of
them?
2. Is it OK for my storage names to be UUIDs? Or is there some dependency
on the small integer naming that I haven't seen?
3. My "register" method will have to call out to another service to get
authorization for access to the named storage. Presumably I can just do
this synchronously?
Bill
--
You received this message because you are subscribed to the Google Groups "zodb" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/d/optout.