Changeset 2670


Ignore:
Timestamp:
Dec 20, 2009, 9:44:19 PM (15 years ago)
Author:
broder
Message:

Get login information from Apache, if available

Location:
package_branches/invirt-web/cherrypy-rebased/code
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • package_branches/invirt-web/cherrypy-rebased/code/main.conf

    r2662 r2670  
    44engine.auto_reload = False
    55tools.mako.module_directory = "/tmp/invirt-web-templatecache"
     6tools.remote_user_login.on = True
    67
    78engine.SIGHUP = None
  • package_branches/invirt-web/cherrypy-rebased/code/main.py

    r2669 r2670  
    691691    return templates.error(searchList=[d])
    692692
    693 def getUser(environ):
    694     """Return the current user based on the SSL environment variables"""
    695     user = environ.get('REMOTE_USER')
    696     if user is None:
    697         return
    698    
    699     if environ.get('AUTH_TYPE') == 'Negotiate':
    700         # Convert the krb5 principal into a krb4 username
    701         if not user.endswith('@%s' % config.kerberos.realm):
    702             return
    703         else:
    704             return user.split('@')[0].replace('/', '.')
    705     else:
    706         return user
    707 
    708693def handler(username, state, path, fields):
    709694    operation, path = pathSplit(path)
  • package_branches/invirt-web/cherrypy-rebased/code/view.py

    r2669 r2670  
    7979            "You are not authorized to access that resource")
    8080
    81 cherrypy.tools.require_login = cherrypy.Tool('on_start_resource', require_login)
     81cherrypy.tools.require_login = cherrypy.Tool('on_start_resource', require_login, priority=150)
     82
     83def remote_user_login():
     84    """Get the current user based on the SSL or GSSAPI environment variables"""
     85    environ = cherrypy.request.wsgi_environ
     86    user = environ.get('REMOTE_USER')
     87    if user is None:
     88        return
     89    else:
     90        cherrypy.request.login = None # clear what cherrypy put there
     91
     92    if environ.get('AUTH_TYPE') == 'Negotiate':
     93        # Convert the krb5 principal into a krb4 username
     94        if not user.endswith('@%s' % config.kerberos.realm):
     95            cherrypy.request.login = False # failed to login
     96        else:
     97            cherrypy.request.login = user.split('@')[0].replace('/', '.')
     98    else:
     99        cherrypy.request.login = user
     100
     101cherrypy.tools.remote_user_login = cherrypy.Tool('on_start_resource', remote_user_login, priority=50)
    82102
    83103def invirtwebstate_init():
Note: See TracChangeset for help on using the changeset viewer.