#auto_reload doesn't work with FastCGI
engine.auto_reload = False
tools.mako.module_directory = "/tmp/invirt-web-templatecache"
+tools.remote_user_login.on = True
engine.SIGHUP = None
engine.SIGTERM = None
d['details'] = details
return templates.error(searchList=[d])
-def getUser(environ):
- """Return the current user based on the SSL environment variables"""
- user = environ.get('REMOTE_USER')
- if user is None:
- return
-
- if environ.get('AUTH_TYPE') == 'Negotiate':
- # Convert the krb5 principal into a krb4 username
- if not user.endswith('@%s' % config.kerberos.realm):
- return
- else:
- return user.split('@')[0].replace('/', '.')
- else:
- return user
-
def handler(username, state, path, fields):
operation, path = pathSplit(path)
if not operation:
raise cherrypy.HTTPError(403,
"You are not authorized to access that resource")
-cherrypy.tools.require_login = cherrypy.Tool('on_start_resource', require_login)
+cherrypy.tools.require_login = cherrypy.Tool('on_start_resource', require_login, priority=150)
+
+def remote_user_login():
+ """Get the current user based on the SSL or GSSAPI environment variables"""
+ 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
+ else:
+ cherrypy.request.login = user.split('@')[0].replace('/', '.')
+ else:
+ cherrypy.request.login = user
+
+cherrypy.tools.remote_user_login = cherrypy.Tool('on_start_resource', remote_user_login, priority=50)
def invirtwebstate_init():
"""Initialize the cherrypy.request.state object from Invirt"""