This commit is contained in:
Yuusuke KOUNOIKE 2017-04-19 02:44:36 +00:00 committed by GitHub
commit a7d4ff905b
4 changed files with 18 additions and 2 deletions

View File

@ -118,6 +118,7 @@ password:
weight: 31
self: True
type: password
# hash: ldap_sha512_crypt
backends:
ldap: userPassword
# ad: unicodePwd

View File

@ -33,6 +33,9 @@ from mako import lookup
from mako import exceptions
from sets import Set
# passlib hash password module import
from passlib.context import CryptContext
SESSION_KEY = '_cp_username'
@ -654,7 +657,12 @@ class LdapCherry(object):
raise PasswordMissMatch()
if not self._checkppolicy(params['attrs'][pwd1])['match']:
raise PPolicyError()
params['attrs'][attr] = params['attrs'][pwd1]
hash_type = self.attributes.attributes[attr].get('hash')
if hash_type:
ctx = CryptContext(schemes=[hash_type])
params['attrs'][attr] = ctx.encrypt(params['attrs'][pwd1])
else:
params['attrs'][attr] = params['attrs'][pwd1]
if attr in params['attrs']:
self.attributes.check_attr(attr, params['attrs'][attr])
backends = self.attributes.get_backends_attributes(attr)
@ -720,7 +728,12 @@ class LdapCherry(object):
params['attrs'][pwd1]
)['match']:
raise PPolicyError()
params['attrs'][attr] = params['attrs'][pwd1]
hash_type = self.attributes.attributes[attr].get('hash')
if hash_type:
ctx = CryptContext(schemes=[hash_type])
params['attrs'][attr] = ctx.encrypt(params['attrs'][pwd1])
else:
params['attrs'][attr] = params['attrs'][pwd1]
if attr in params['attrs'] and params['attrs'][attr] != '':
self.attributes.check_attr(attr, params['attrs'][attr])
backends = self.attributes.get_backends_attributes(attr)

View File

@ -2,3 +2,4 @@ CherryPy>=3.0.0
PyYAML
Mako
python-ldap
passlib

View File

@ -25,6 +25,7 @@ if sys.version_info[0] == 2:
install_requires = [
'CherryPy >= 3.0.0',
'python-ldap',
'passlib',
'PyYAML',
'Mako'
],