mirror of
https://github.com/kakwa/ldapcherry
synced 2024-11-24 10:14:31 +01:00
enable password hash.
This commit is contained in:
parent
e56835d4f4
commit
a07b7d48c5
@ -31,6 +31,9 @@ from mako.template import Template
|
||||
from mako import lookup
|
||||
from sets import Set
|
||||
|
||||
# passlib hash password module import
|
||||
from passlib.context import CryptContext
|
||||
|
||||
SESSION_KEY = '_cp_username'
|
||||
|
||||
|
||||
@ -596,6 +599,11 @@ class LdapCherry(object):
|
||||
raise PasswordMissMatch()
|
||||
if not self._checkppolicy(params['attrs'][pwd1])['match']:
|
||||
raise PPolicyError()
|
||||
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])
|
||||
@ -653,6 +661,11 @@ class LdapCherry(object):
|
||||
params['attrs'][pwd1]
|
||||
)['match']:
|
||||
raise PPolicyError()
|
||||
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])
|
||||
|
Loading…
Reference in New Issue
Block a user