Changeset 2263
- Timestamp:
- 05/27/07 00:11:55 (2 years ago)
- Files:
-
- modauthacctmgrscript/0.9/mod_auth_acctmgr/handler.py (modified) (2 diffs)
- modauthacctmgrscript/0.9/mod_auth_acctmgr/__init__.py (modified) (1 diff)
- modauthacctmgrscript/0.9/mod_auth_acctmgr/perms.py (added)
- modauthacctmgrscript/0.9/setup.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
modauthacctmgrscript/0.9/mod_auth_acctmgr/handler.py
r1257 r2263 4 4 from mod_python import apache 5 5 from trac.web.main import _open_environment 6 from trac.perm import PermissionSystem 6 7 7 8 acct_mgr = None 8 9 9 def authenhandler(req): 10 global acct_mgr 11 pw = req.get_basic_auth_pw() 12 user = req.user 13 10 def _get_env(req): 11 """Get the Environment object for a request.""" 14 12 # Find the env_path from the Apache config 15 13 options = req.get_options() 16 14 if 'TracEnv' not in options: 17 15 print 'Must specify a Trac environment' 18 return apache.HTTP_FORBIDDEN16 return None 19 17 env_path = options['TracEnv'] 20 18 21 # Try loading the env from the global cache, addit it if needed 22 env = _open_environment(env_path) 23 19 # Try loading the env from the global cache, add it it if needed 20 return _open_environment(env_path) 21 22 def authenhandler(req): 23 pw = req.get_basic_auth_pw() 24 user = req.user 25 26 env = _get_env(req) 27 if env is None: 28 return apache.HTTP_FORBIDDEN 29 30 global acct_mgr 24 31 if acct_mgr is None: 25 32 from acct_mgr.api import AccountManager … … 31 38 return apache.HTTP_UNAUTHORIZED 32 39 40 def authzhandler(req): 41 user = req.user 42 43 env = _get_env(req) 44 if env is None: 45 return apache.DECLINED 46 47 options = req.get_options() 48 if 'TracPerm' not in options: 49 print 'You must specify a permission' 50 return apache.DECLINED 51 perm = options['TracPerm'] 52 53 user_perms = PermissionSystem(self.env).get_user_permissions(user) 54 if user_perms.get(perm): 55 return apache.OK 56 else: 57 return apache.DECLINED 58 modauthacctmgrscript/0.9/mod_auth_acctmgr/__init__.py
r1108 r2263 1 from handler import * modauthacctmgrscript/0.9/setup.py
r1108 r2263 9 9 packages = ['mod_auth_acctmgr'], 10 10 #package_data={ 'mod_auth_acctmgr' : [ ] }, 11 11 12 author = "Noah Kantrowitz", 12 13 author_email = "coderanger@yahoo.com", … … 17 18 url = "http://trac-hacks.org/wiki/ModAuthAcctmgrScript", 18 19 zip_safe = False, 20 21 classifiers = [ 22 'Framework :: Trac', 23 ], 24 25 install_requires = ['TracAccountManager'], 26 27 entry_points = { 28 'trac.plugins': [ 29 'mod_auth_acctmgr.perms = mod_auth_acctmgr.perms', 30 ] 31 }, 19 32 )
