From dfa7ab2f525e746b78fee0fa4bfe47ee38d27205 Mon Sep 17 00:00:00 2001 From: Greg Price Date: Sat, 19 Dec 2009 22:00:06 -0500 Subject: [PATCH 1/1] view.py: clean up remote_user_login Remove dead code, and make the docstring clear about what the function is actually doing. svn path=/package_branches/invirt-web/cherrypy-rebased/; revision=2722 --- code/view.py | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/code/view.py b/code/view.py index 4135e24..e67f710 100644 --- a/code/view.py +++ b/code/view.py @@ -115,26 +115,23 @@ def require_POST(): cherrypy.tools.require_POST = cherrypy.Tool('on_start_resource', require_POST, priority=150) def remote_user_login(): - """Get the current user based on the SSL or GSSAPI environment -variables and store it in the request object's login variable. This -conforms to the CherryPy API: -http://www.cherrypy.org/wiki/RequestObject#login - -If the user is logged in successfully, cherrypy.request.login is set -to the username. If the user failed to log in, cherrypy.request.login -is set to False. If the user did not attempt authentication, -cherrypy.request.login is set to None.""" + """Get remote user from SSL or GSSAPI, and store in request object. + +Get the current user based on environment variables set by SSL or +GSSAPI, and store it in the attribute cherrpy.request.login. + +Per the CherryPy API (http://www.cherrypy.org/wiki/RequestObject#login), +the attribute is set to the username on successful login, to False on +failed login, and is left at None if the user attempted no authentication. +""" environ = cherrypy.request.wsgi_environ user = environ.get('REMOTE_USER') if user is None: return - else: - cherrypy.request.login = None # clear what cherrypy put there - if environ.get('AUTH_TYPE') == 'Negotiate': # Convert the krb5 principal into a krb4 username if not user.endswith('@%s' % config.kerberos.realm): - cherrypy.request.login = False # failed to login + cherrypy.request.login = False # failed to log in else: cherrypy.request.login = user.split('@')[0].replace('/', '.') else: -- 1.7.9.5