[mod_python] Another authentication issue? Or am I missing something?

Sean True seant at alum.mit.edu
Thu Sep 7 19:04:17 EST 2000

I've been having trouble getting PythonAuthenHandler-s to work properly. On
my Microsoft IE 5.5 browser,
the password dialog was not popping up. After some digging (Writing Apache
Modules in Perl and C is-your-friend), I found on page 284 the
reccomendation that one call req.note_basic_auth-failure, a perl method, to
force the WWW-Authenticate field in the HTTP headers to be set. This will
cause the browser to pop a password dialog.

Since that method is not exposed in Python (wouldn't Swig make this a lot
easier?), I added the following code to mod_python.c
and things worked much better, first try:

	    /* SDT If an AuthenHandler and we failed, note failure */
	    if (strcmp(handler, "PythonAuthenHandler") == 0) {
	      if ((result == HTTP_UNAUTHORIZED)){
	    /* Original code continues */
	    /* authen handlers need one more thing
	     * if authentication failed and this handler is not
	     * authoritative, let the others handle it
	      if (strcmp(handler, "PythonAuthenHandler") == 0) {
		if ((result == HTTP_UNAUTHORIZED) &&
		    (! conf->authoritative)) {
		  result = DECLINED;

Any comments? Other than the obvious proper factoring of the if expression

-- Sean
Sean True
Webreply, Inc.

More information about the Mod_python mailing list