1
0
mirror of https://github.com/kakwa/ldapcherry synced 2024-06-03 01:28:06 +02:00

enable password hash.

This commit is contained in:
Yuusuke KOUNOIKE 2016-06-18 22:38:01 +09:00
parent e56835d4f4
commit a07b7d48c5

View File

@ -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])