apache 2.2与mod_python 3.2.10 验证的问题解决
apache 2.2与mod_python 3.2.10 验证的问题解决:
环境:apache2.2.3/mod_python 3.2.10
配置文件:
apache:
SetHandler mod_python
PythonHandler mod_python.publisher
PythonAuthenHandler bin.authhandler
PythonDebug On
PythonAutoReload Off
PythonPath "sys.path+['/webapp/dorm/web']"
AuthType Basic
AuthName "Restricted Area"
require valid-user
python:
(/webapp/dorm/web/bin/authhandler文件):
# -*- coding: UTF-8 -*-
from mod_python import apache
def authenhandler(req):
pw=req.get_basic_auth_pw()
user=req.user
if user=="test" and pw=="test":
return apache.OK
else:
return apache.HTTP_UNAUTHORIZED
问题描述:
在使用浏览器进入/webapp/dorm/web/admin目录来进行验证的时候出现:
" No Authn provider configured "的错误。
经检查apache的模块,发现已经加载了:
LoadModule authz_user_module modules/mod_authz_user.so
LoadModule auth_basic_module modules/mod_auth_basic.so
按理说mod_python 3.2.10已经支持apache2.2了的,可是为什么还是验证不了呢?
查找相关的资料,看到:
Module Developer Changes
APR 1.0 API
Apache 2.2 uses the APR 1.0 API. All deprecated functions and symbols have been removed from APR and APR-Util. For details, see the APR Website.
Authn/Authz
The bundled authentication and authorization modules have been renamed along the following lines:
mod_auth_* -> Modules that implement an HTTP authentication mechanism
mod_authn_* -> Modules that provide a backend authentication provider
mod_authz_* -> Modules that implement authorization (or access)
mod_authnz_*-> Module that implements both authentication & authorization
There is a new authentication backend provider scheme which greatly eases the construction of new authentication backends.
其中的:mod_authn_* -> Modules that provide a backend authentication provider
使我想到是不是模块本身的问题呢?
抱着试试看的心情重新编译了一次mod_auth_basic模块:
步骤:
进入apache安装的源码包,
# find . -name "*auth_basic*.c"
./modules/aaa/mod_auth_basic.c
# cd ./modules/aaa
# /opt/apache/bin/apxs -c mod_auth_basic.c
# /opt/apache/bin/apxs -i -a -n auth_basic mod_auth_basic.la
然后进入httpd.conf的配置文件将原来的LoadModule auth_basic_module modules/mod_auth_basic.so给注释掉,重新启动apache,居然可以了!