[mod_python] Problem with win32 installation - can't authenticate

Jacob Martinson jmartinson at info234.com
Thu Jul 10 17:00:03 EST 2003

My problem: after installing apache(win32), python(win32) and 
modpython(win32) the basic test works for returning 'hello world' but when 
i try the authentication example from the documentation, I am not able to 
authenticate.  After a little investigation, I find that both req.user and 
req.get_basic_auth_pw() are None.

I am prompted for username/password, but I can't authenticate 
successfully.  Also, if I ignore req.user and password and just return 
apache.OK, it allows me to access the file I am requesting.

Here's the relevant parts of my apache config:

LoadModule python_module modules/mod_python.so

<Directory "c:\Documents and Settings\jmartinson\docroot">
   AddHandler python-program .py
   PythonHandler mptest
   PythonDebug On

<Directory "c:\Documents and Settings\jmartinson\docroot\test1">
     AddHandler python-program .py
     PythonHandler myscript
     PythonAuthenHandler myscript
     PythonDebug Off
     AuthType Basic
     AuthName "Restricted Area"
     require valid-user

Here's my handler (myscript.py):

from mod_python import apache
def authenhandler(req):
         user = req.user
         pw = req.get_basic_auth_pw()
         req.write( str(user) + ':' + str(pw) + str('\n') )
         return apache.OK

         if user == "spam":
                 return apache.OK
                 return apache.HTTP_UNAUTHORIZED

I put in the first "return apache.OK" for testing purposes.  If I take that 
out authentication still won't work.  I also took out the second half of 
the if statement testing the password too.

Version info:
python: http://python.org/ftp/python/2.2.3/Python-2.2.3.exe

I would much rather be using modpython under a unix environment, but I am 
doing this on my work laptop and I don't have the option of eliminating the 
Windows environment and I can't get apache to compile under cygwin.

Any information or suggestions are greatly appreciated!


More information about the Mod_python mailing list