[Zope-CVS] CVS: Products/PluggableAuthService/plugins -
ZODBUserManager.py:1.5
Zachery Bir
zbir at urbanape.com
Mon Aug 30 11:28:45 EDT 2004
Update of /cvs-repository/Products/PluggableAuthService/plugins
In directory cvs.zope.org:/tmp/cvs-serv19672
Modified Files:
ZODBUserManager.py
Log Message:
Use AccessControl.AuthEncoding for all passwords going forward (but
provide backwards compatibility for pre-existing ZODBUserManagers)
=== Products/PluggableAuthService/plugins/ZODBUserManager.py 1.4 => 1.5 ===
--- Products/PluggableAuthService/plugins/ZODBUserManager.py:1.4 Mon Aug 30 09:22:41 2004
+++ Products/PluggableAuthService/plugins/ZODBUserManager.py Mon Aug 30 11:28:45 2004
@@ -18,7 +18,7 @@
"""
import sha
-from AccessControl import ClassSecurityInfo
+from AccessControl import ClassSecurityInfo, AuthEncoding
from AccessControl.SecurityManagement import getSecurityManager
from App.class_init import default__class_init__ as InitializeClass
from BTrees.OOBTree import OOBTree
@@ -91,9 +91,15 @@
return (None, None)
userid = self._login_to_userid.get( login, login )
+ reference = self._user_passwords[ userid ]
+ if AuthEncoding.is_encrypted( reference ):
+ if AuthEncoding.pw_validate( reference, password ):
+ return userid, login
+
+ # Support previous naive behavior
digested = sha.sha( password ).hexdigest()
-
- if self._user_passwords.get( userid ) == digested:
+
+ if reference == digested:
return userid, login
return (None, None)
@@ -225,7 +231,7 @@
if self._login_to_userid.get( login_name ) is not None:
raise KeyError, 'Duplicate login name: %s' % login_name
- self._user_passwords[ user_id ] = sha.sha( password ).hexdigest()
+ self._user_passwords[ user_id ] = AuthEncoding.pw_encrypt( password )
self._login_to_userid[ login_name ] = user_id
self._userid_to_login[ user_id ] = login_name
@@ -255,7 +261,7 @@
self._userid_to_login[ user_id ] = login_name
if password:
- digested = sha.sha( password ).hexdigest()
+ digested = AuthEncoding.pw_encrypt( password )
self._user_passwords[ user_id ] = digested
#
More information about the Zope-CVS
mailing list