[mod_python] Query about authentication/authorization win Apache on Win32

Nik Barron Nik.Barron at pennantplc.co.uk
Thu Apr 11 16:18:17 EST 2002


Hi,

I have a problem getting authentication/authorization working. In Apache I
have the following:

   <IfModule mod_python.c>
    <Directory "C:/Programs/Internet/Apache/htdocs/plcsreqs">
	AddHandler python-program .py
   	PythonHandler test2
	PythonAuthenHandler test2
   	PythonDebug on

	AuthType Basic
	AuthName "nicepeople"
	AuthUserFile "C:/Programs/Internet/Apache/conf/users"
	Require valid-user
    </Directory>
  </IfModule>

The Auth... stuff works fine for a "normal" directory, so the file is
readable etc, and my mod_python script works fine with no authentication.

My test script has an authenhandler as follows:

  def authenhandler(req):
	
	global user

	pw = req.get_basic_auth_pw()
	user = req.connection.user
	
	return apache.OK

Currently all I want to do is grab the user's name from their Apache login.

Now, if the user logs in to another page on the site before going to the
mod_python script, everything works as expected and the username is passed
to the rest of my code in the global variable 'user'. 

But if you go directly to the mod_python script (e.g.
http://myhost/plcsreq/test.py), it goes through as "None", and the broswer
doesn't pop up a username/password box.

I'm guessing this is going to be some stupid error on my part, but I can't
seem to get it working. Any suggestions most welcome.

Thanks!

Nick Barron
Manager, E-Services Division
Pennant Information Services Ltd -- Registered in England No. 3772667
PGP: A94C 4190 026E 3E02 6D50  C8FA 8620 3091 FF34 533D



More information about the Mod_python mailing list