Ignore:
Timestamp:
Dec 20, 2009, 9:45:38 PM (14 years ago)
Author:
broder
Message:

Implement administrator mode

File:
1 edited

Legend:

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

    r2689 r2690  
    5656                                                 'from invirt import database']
    5757
     58    def __getattr__(self, name):
     59        if name in ("admin", "overlord"):
     60            if not cherrypy.request.login in getAfsGroupMembers(config.adminacl, config.authz[0].cell):
     61                raise InvalidInput('username', cherrypy.request.login,
     62                                   'Not in admin group %s.' % config.adminacl)
     63            cherrypy.request.state = State(cherrypy.request.login, isadmin=True)
     64            return self
     65        else:
     66            return super(InvirtWeb, self).__getattr__(name)
    5867
    5968    @cherrypy.expose
     
    646655            'hostname' : socket.getfqdn()}])
    647656
    648 def admin(username, state, path, fields):
    649     if path == '':
    650         return ({'Status': '303 See Other',
    651                  'Location': 'admin/'},
    652                 "You shouldn't see this message.")
    653     if not username in getAfsGroupMembers(config.adminacl, 'athena.mit.edu'):
    654         raise InvalidInput('username', username,
    655                            'Not in admin group %s.' % config.adminacl)
    656     newstate = State(username, isadmin=True)
    657     newstate.environ = state.environ
    658     return handler(username, newstate, path, fields)
    659 
    660657mapping = dict(
    661658               modify=modify,
    662                unauth=unauthFront,
    663                admin=admin,
    664                overlord=admin)
     659               unauth=unauthFront)
    665660
    666661def printHeaders(headers):
Note: See TracChangeset for help on using the changeset viewer.