Changeset 2265

Show
Ignore:
Timestamp:
05/27/07 01:41:10 (2 years ago)
Author:
coderanger
Message:

ModAuthAcctmgrScript:

Working version of the permissions check.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modauthacctmgrscript/0.9/mod_auth_acctmgr/handler.py

    r2263 r2265  
    1313    options = req.get_options() 
    1414    if 'TracEnv' not in options: 
    15         print 'Must specify a Trac environment' 
     15        req.log_error('mod_auth_acctmgr: Must specify a Trac environment') 
    1616        return None 
    1717    env_path = options['TracEnv'] 
     
    2323    pw = req.get_basic_auth_pw() 
    2424    user = req.user 
    25  
     25     
    2626    env = _get_env(req) 
    2727    if env is None: 
     
    3333        acct_mgr = AccountManager 
    3434 
     35    options = req.get_options() 
     36    #if 'TracPerm' not in options: 
     37    #    req.log_error('mod_auth_acctmgr: You must specify a permission') 
     38    #    return apache.HTTP_FORBIDDEN 
     39    perm = options.get('TracPerm') 
     40 
    3541    if acct_mgr(env).check_password(user, pw): 
     42        if perm: 
     43            user_perms = PermissionSystem(env).get_user_permissions(user) 
     44            if not user_perms.get(perm): 
     45                return apache.HTTP_FORBIDDEN 
    3646        return apache.OK 
    3747    else: 
    3848        return apache.HTTP_UNAUTHORIZED 
    3949 
    40 def authzhandler(req): 
     50def perms(req): 
    4151    user = req.user 
    4252     
    4353    env = _get_env(req) 
    4454    if env is None: 
    45         return apache.DECLINED 
     55        return apache.HTTP_FORBIDDEN 
    4656         
    4757    options = req.get_options() 
    4858    if 'TracPerm' not in options: 
    49         print 'You must specify a permission' 
    50         return apache.DECLINED 
     59        req.log_error('mod_auth_acctmgr: You must specify a permission') 
     60        return apache.HTTP_FORBIDDEN 
    5161    perm = options['TracPerm'] 
    5262     
     
    5565        return apache.OK 
    5666    else: 
    57         return apache.DECLINED 
     67        return apache.HTTP_FORBIDDEN 
    5868     
  • modauthacctmgrscript/0.9/mod_auth_acctmgr/__init__.py

    r2263 r2265  
    1 from handler import * 
     1# This allows "PythonAuthnHandler mod_auth_acctmgr" instead of "PythonAuthnHandler mod_auth_acctmgr.handler"  
     2try: 
     3    from handler import * 
     4except ImportError: 
     5    pass