-----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          tsea...@palladion.com
Palladion Software   "Excellence by Design"    http://palladion.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)

iQIcBAEBAgAGBQJVbczTAAoJEPKpaDSJE9HYT+4P/3bu4hMoDyBHMzjt82G9C/Ik
jmCCCWJidZcYTHdW6mhXtmkZENd2eFiPuJCPrusH7hU+PuDk9ymPAQu5FOh2w5wb
YjsJtrBIDIYEdDq1ArsqOvbwjLeSb0YLHuORrIB7lh2Ic9BKuYtX93FgcLdhq4Fn
oeQvRZ965YtSXwGi4F4TGS5Fr52m8rWDh5/qs/Km1OsGFgI5cF0Aam5nF3vN3IVt
ykFsxtA19/I+FWBKkrTKEuhZTIjqKAONGY3eApsgEhEySklo/FblRSLWmUqWAZXQ
uAl7CSJZD1Qi2yUU/z2T0H6e+RIIk8nbrFVzl3BZjj1QbMJmVpOy+BRFC8VzrC5i
HVHJdVzshVQrORH1qt87S8hHUlk/CwAJng8ALBlF8uBgt2atwbuED6EqSSiMQXj/
eJMesN1aKF8p0I/nG2ItBb/Y0HmiX4y5NcAvKDvhmvqS4rc4GPm67IADQw73nLVC
tcXjHx4EeqYmDP0fs4RwEX5PWrpBuTc3etdd2/YIMBr6WhUPX0uDdUM+Bq9Z/ngL
Cof7CBa2I4FTIr82xd07eS0EqdUq0J992Chk1eMfxegqFTrkI8bJ9/JZuL1l+0pK
tSa8qSQCwR3ClCneDpFLzG0A6QGQoj2nyzkGb6nql/xwPdr7qgMW+fAwdzjDI7ab
2Oytr7Uz6TG/jYjoJzjU
=OSbv
-----END PGP SIGNATURE-----

_______________________________________________
Zope maillist  -  Zope@zope.org
https://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists -
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope-dev )

Reply via email to