From fadf670eedb9058cd74538d1e36b46eaaa233db6 Mon Sep 17 00:00:00 2001 From: Andrea Cimbalo Date: Fri, 9 Jun 2017 19:46:58 +0200 Subject: [PATCH] unauthenticated errors string --- lilikusers.py | 6 +++++- server.py | 6 ++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/lilikusers.py b/lilikusers.py index bf1cca0..113ba3d 100644 --- a/lilikusers.py +++ b/lilikusers.py @@ -88,7 +88,11 @@ class LILiK_USER(object): raise NameError('Unknown user attribute: %s'%service_changed) elif changed in self._attributes: 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]['givenname'] = [(ldap3.MODIFY_REPLACE, [firstname])] modifiers[user_cn][changed] = [(ldap3.MODIFY_REPLACE, [new_lilik_user[changed]])] diff --git a/server.py b/server.py index 21c3e9a..76a4e82 100755 --- a/server.py +++ b/server.py @@ -21,15 +21,13 @@ def authenticate(): """Sends a 401 response that enables basic auth""" return Response( '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(): """Sends a 401 response that enables basic auth""" return Response( '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): @wraps(f)