Hello Tres (maintainer of PAS) and Zope community,
I’m trying to get PAS replace CookieCrumpler to do authentication to Zope2 from a python script/Product or external method.
Is there a how-to or tutorial somewhere how to get started on this?
What I want is to authenticate a user through a web login form as Cookie Crumbler does (but I’d like to to it from my own script that does other things,too).
I’ve
- installed PAS - replaced the default acl_users in my folder - added a ZODB user folder - added a CookieAuthHelper
Now, how do I authenticate the user to Zope if I have a username and password (i.e. from request.get(‚username‘) etc.)
Best regards Sebastian
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On 06/01/2015 05:01 PM, Sebastian Tänzer wrote:
Hello Tres (maintainer of PAS) and Zope community,
I’m trying to get PAS replace CookieCrumpler to do authentication to Zope2 from a python script/Product or external method.
Is there a how-to or tutorial somewhere how to get started on this?
What I want is to authenticate a user through a web login form as Cookie Crumbler does (but I’d like to to it from my own script that does other things,too).
I’ve
- installed PAS - replaced the default acl_users in my folder - added
a ZODB user folder - added a CookieAuthHelper
Now, how do I authenticate the user to Zope if I have a username and password (i.e. from request.get(‚username‘) etc.)
You can check credentials from trusted code by calling the 'ZODBUserFolder' instance's 'authenticateCredentials()' method, passing in a dictionary containing 'login' and 'password' keys. E.g.::
zodb_users = self.unrestrictedTraverse('/acl_users/zodb_users') creds = {'login': login_name, 'password': password} authenticated = zodb_users.authenticateCredentials(creds)
if authenticated is None: # creds don't match show_error_message() else: userid, login = authenticated
Tres. - -- =================================================================== Tres Seaver +1 540-429-0999 tseaver@palladion.com Palladion Software "Excellence by Design" http://palladion.com