[Zope3-Users] Re: Does zope cache authentication?

Jodok Batlogg jodok at lovelysystems.com
Sat Sep 22 14:16:34 EDT 2007


On 22.09.2007, at 19:16, Philipp von Weitershausen wrote:

> Jodok Batlogg wrote:
>>> I have written a custom authenticator in my application to
>>> authenticate a login against a PostgreSQL database. In the site I  
>>> have
>>> configured a PAU with a session credentials plugin and my custom
>>> authenticator plugin.
>>>
>>> I found out that with configuration, EVERY browser request is
>>> triggering my custom authenticator, which means a query of the
>>> database. I'd rather expect only the first login will send a  
>>> database
>>> request, and before one logs out, subsequent requests will no longer
>>> be authenticated.
>> exactly, that's the default behavior. and it needs to be that way.
>> in case the credentials are beeing changed or privileges are  
>> beeing  revoked there are several use cases where you can't cache.
>>> Does the PAU have a mechanism to cache the authentication before the
>>> user is logged out? Otherwise the authentication would be a highly
>>> inefficient process.
>> you need to implement caching on your own...
>> just do something like:
>> from zope.app.cache.ram import RAMCache
>> authCache = RAMCache()
>> key = {'user': credentials['login'].encode('utf-8'), 'pass':  
>> credentials['password'].encode('utf-8')}
>> result = authCache.query(self, key=key)
>> if result is None:
>>     # perform database lookup
>>     authCache.set(result, self, key=key)
>> return result
>
> What's with the encoding to utf-8? Coudln't you simply use unicode?

well the snipped was just copied from our code. probably we receive  
the password somehow different.
it should be possible to use unicode

jodok

>
> Note that you can also use sessions.
>
>
> -- 
> http://worldcookery.com -- Professional Zope documentation and  
> training
>
> _______________________________________________
> Zope3-users mailing list
> Zope3-users at zope.org
> http://mail.zope.org/mailman/listinfo/zope3-users

--
"Readability counts."
   -- The Zen of Python, by Tim Peters

Jodok Batlogg, Lovely Systems
Schmelzhütterstraße 26a, 6850 Dornbirn, Austria
phone: +43 5572 908060, fax: +43 5572 908060-77


-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2454 bytes
Desc: not available
Url : http://mail.zope.org/pipermail/zope3-users/attachments/20070922/ce8461db/smime.bin


More information about the Zope3-users mailing list