[mod_python] authenhandler and authzhandler

John marshalljd2 at yahoo.ca
Sun Feb 27 21:45:39 EST 2005


I have been trying the follow the documentation to
use the authenhandler and authzhandler. authenhandler
(and accesshandler, btw) seems to be working, but the
authzhandler never gets called. I have tried different
configurations, etc. I do not have anything fancy.

I have also checked my setup against what others have
claimed worked for them.

I hope someone can help me figure this out.

Thanks for any help you can offer.

This is what I have in my python handler program:
def handler(req):
    uri = req.uri
    normuri = normpath(uri)

    apache.log_error("handler uri: %s, normuri: %s" % (uri, normuri))
    req.content_type = "text/html"
    req.write("Hello World!\n")

    return apache.OK

def authenhandler(req):
    pw = req.get_basic_auth_pw()
    userName = req.user

    uri = req.uri
    normuri = normpath(uri)

    apache.log_error("authenhandler uri: %s, normuri: %s, userName: %s" % (uri, normuri, userName))
    return apache.OK

def authzhandler(req):
    """Authorize the incoming request for the filesystem-based uri.
    uri = req.uri
    normuri = normpath(uri)

    apache.log_error("authzhandler uri: %s, normuri: %s" % (uri, normuri))

    return apache.OK

def accesshandler(req):
    """Check access of the incoming request for the filesystem-based uri.
    uri = req.uri
    normuri = normpath(uri)

    apache.log_error("accesshandler uri: %s, normuri: %s" % (uri, normuri))

    return apache.OK

My apache site config is:
<VirtualHost *:8080>
	DocumentRoot		/var/www/portal
	UserDir			disabled root

	<Directory />
		AllowOverride	None

	<Directory "/var/www/portal">
		AuthType	Basic
		AuthName	"Test Portal"
		Require		valid-user
		AllowOverride	None
		Order		deny,allow
		Deny		from all
		Allow		from

		PythonDebug	On
		SetHandler	mod_python
		PythonHandler	portal
		PythonAccessHandler	portal
		PythonAuthenHandler	portal
		PythonAuthzHandler	portal

	ErrorLog /var/log/apache2/error.log

	# Possible values include: debug, info, notice, warn, error, crit,
	# alert, emerg.
	#LogLevel warn
	LogLevel info

	CustomLog /var/log/apache2/access.log combined
	#ServerSignature On

More information about the Mod_python mailing list