Browse Source

unauthenticated errors string

master
Andrea Cimbalo 8 years ago
parent
commit
fadf670eed
2 changed files with 7 additions and 5 deletions
  1. +5
    -1
      lilikusers.py
  2. +2
    -4
      server.py

+ 5
- 1
lilikusers.py View File

@ -88,7 +88,11 @@ class LILiK_USER(object):
raise NameError('Unknown user attribute: %s'%service_changed) raise NameError('Unknown user attribute: %s'%service_changed)
elif changed in self._attributes: elif changed in self._attributes:
if changed == 'cn': if changed == 'cn':
firstname, surname = new_lilik_user[changed].rsplit(' ', 1)
try:
firstname, surname = new_lilik_user[changed].strip().rsplit(' ', 1)
except ValueError:
firstname = new_lilik_user[changed].strip()
surname = " "
modifiers[user_cn]['sn'] = [(ldap3.MODIFY_REPLACE, [surname])] modifiers[user_cn]['sn'] = [(ldap3.MODIFY_REPLACE, [surname])]
modifiers[user_cn]['givenname'] = [(ldap3.MODIFY_REPLACE, [firstname])] modifiers[user_cn]['givenname'] = [(ldap3.MODIFY_REPLACE, [firstname])]
modifiers[user_cn][changed] = [(ldap3.MODIFY_REPLACE, [new_lilik_user[changed]])] modifiers[user_cn][changed] = [(ldap3.MODIFY_REPLACE, [new_lilik_user[changed]])]


+ 2
- 4
server.py View File

@ -21,15 +21,13 @@ def authenticate():
"""Sends a 401 response that enables basic auth""" """Sends a 401 response that enables basic auth"""
return Response( return Response(
'Could not verify your access level for that URL.\n' 'Could not verify your access level for that URL.\n'
'You have to login with proper credentials\n', 401,
{'WWW-Authenticate': 'Basic realm="Login Required"'})
'You have to login with proper credentials\n', 401)
def admin_required(): def admin_required():
"""Sends a 401 response that enables basic auth""" """Sends a 401 response that enables basic auth"""
return Response( return Response(
'Could not verify your access level for that URL.\n' 'Could not verify your access level for that URL.\n'
'You have to login with admin rights\n', 401,
{'WWW-Authenticate': 'Basic realm="Admin login Required"'})
'You have to login with admin rights\n', 401)
def requires_auth(f): def requires_auth(f):
@wraps(f) @wraps(f)


Loading…
Cancel
Save