Skip to content
Snippets Groups Projects
Commit 27382f91 authored by ale's avatar ale
Browse files

add shard information to the User

parent 71310004
No related branches found
No related tags found
No related merge requests found
......@@ -7,6 +7,15 @@ from ldap.ldapobject import LDAPObject
from authserv import model
# Define the LDAP schema attributes that we will use.
SCHEMA = {
'password': 'userPassword',
'otp_secret': 'totpSecret',
'app_specific_password': 'appSpecificPassword',
'shard': 'host'
}
class Error(Exception):
pass
......@@ -101,16 +110,19 @@ class User(model.User):
self._dn = dn
self._otp_enabled = False
self._asps = []
self._shard = None
for key, values in data.iteritems():
if key == 'userPassword':
if key == SCHEMA['password']:
self._password = values[0]
if self._password.startswith('{crypt}'):
self._password = self._password[7:]
elif key == 'totpSecret':
elif key == SCHEMA['otp_secret']:
self._otp_enabled = True
self._totp_secret = values[0]
elif key == 'appSpecificPassword':
elif key == SCHEMA['app_specific_password']:
self._asps = [v.split(':', 1) for v in values]
elif SCHEMA['shard'] and key == SCHEMA['shard']:
self._shard = values[0]
def otp_enabled(self):
return self._otp_enabled
......@@ -129,3 +141,6 @@ class User(model.User):
def get_password(self):
return self._password
def get_shard(self):
return self._shard
......@@ -31,4 +31,5 @@ class User(object):
def get_password(self):
pass
def get_shard(self):
pass
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment