我有以下设置,
WSGIScriptAlias /i C:/Project/Scripts/hello.wsgi WSGIScriptAlias /hello C:/Project/Scripts/hello.wsgi <Directory "C:/Project/Scripts"> Order deny,allow Allow from all </Directory> <Location /i> AuthType Basic AuthName "Top Secret" AuthBasicProvider wsgi WSGIAuthUserScript C:/Project/Scripts/authn.wsgi WSGIAccessScript C:/Project/Scripts/auths.wsgi Require valid-user </Location> <Location /hello> AuthType Basic AuthName "Top Secret" AuthBasicProvider wsgi WSGIAuthUserScript C:/Project/Scripts/authn.wsgi Require valid-user </Location>
authn
def check_password(environ, user, password): if user == 'admin' or user == 'spy': if password == 'secret': return True return False return None
auths中
def allow_access(environ, host): if environ.get('REMOTE_USER'): if environ['REMOTE_USER'] == 'admin': return True return False
请求_http:// localhost / hello按预期popuplogin请求…它工作正常!
请求_http:// localhost /我不popuplogin并返回403 Forbidden
我错过了什么? 是不是WSGIAccessScript应该做授权?
谢谢 :\
编辑
我得到了关键'REMOTE_USER'的错误。
我认为auth脚本没有运行:S
编辑
我正在testing这个基于数据库信息做多个Subversion版本库的授权,
有一种方法可以做到这一点返回403禁止,如果通过身份validation,并没有授权?
我知道这是可能的mod_python,但我不想混合mod_python与mod_wsgi。
不,WSGIAccessScript不是用于用户授权的,它纯粹用于基于主机的访问控制,而不pipe用户是否已被authentication或授权。 用户授权是使用WSGIAuthGroupScript指令处理的。 看到:
http://code.google.com/p/modwsgi/wiki/AccessControlMechanisms#Apache_Group_Authorisation