Hash password

This commit is contained in:
uid 2020-10-10 12:59:41 +02:00
parent affcc47fe9
commit 86e8ed669b
2 changed files with 6 additions and 2 deletions

View File

@ -1,4 +1,5 @@
from ldap3 import ALL_ATTRIBUTES
from ldap3 import ALL_ATTRIBUTES, HASHED_SALTED_SHA
from ldap3.utils.hashed import hashed
from phi.ldap.utils import get_response, make_user_dict, add_entry, delete_entry
from phi.logging import get_logger
@ -50,6 +51,7 @@ def get_all_users(client):
def add_user(client, uid, cn, sn, mail, password):
dn = 'uid={},ou=Hackers,{}'.format(uid, client.base_dn)
hashed_password = hashed(HASHED_SALTED_SHA, password)
attributes={
'objectClass': [
@ -60,7 +62,7 @@ def add_user(client, uid, cn, sn, mail, password):
'cn': cn,
'sn': sn,
'mail': mail,
'userPassword': password # TODO: use hashed password
'userPassword': hashed_password
}
add_entry(client, dn, attributes)

View File

@ -92,6 +92,8 @@ def test_add_to_group(ldap_client):
assert len(group_members) == 2
assert user['uid'] in group_members
# print(group_members)
# print(user)
delete_user(client, user)