[mod_python] I can access mod_ssl cert env vars using PerlAuthenHandler, but howto do it with a PythonAuthenHandler?

Gregory (Grisha) Trubetskoy grisha at modpython.org
Thu Oct 2 14:39:50 EST 2003



On Wed, 1 Oct 2003 perry.tew at cibavision.novartis.com wrote:

> So, my perl code looks like this:
> ##########################################
> my $subr = $r->lookup_uri($r->uri);
> my $env = $subr->subprocess_env;
> my $cn = $env->{'SSL_CLIENT_S_DN_CN'};
> my $dn = $env->{'SSL_CLIENT_S_DN'};
> ##########################################

It looks like mod_perl's lookup_uri returns the new request object, which
is rather clever, we should adopt this in mod_python :-)

> I'm trying to do the same thing in python with this:
> ############################################
>         req.internal_redirect(req.unparsed_uri)
>         req.add_common_vars()
>         for k, v in req.subprocess_env.items():
>                 msg = k + "=" + v
>                 apache.log_error( msg , apache.APLOG_NOTICE )
>
> ############################################

Try this instead:

         req.internal_redirect(req.unparsed_uri)
         req.next.add_common_vars()
         for k, v in req.next.subprocess_env.items():
                 msg = k + "=" + v
                 apache.log_error( msg , apache.APLOG_NOTICE )


Notice "req.next" instead of "req"

Also - don't know if your handler does this elsewhere, but I think that
req.internal_redirect(req.unparsed_uri) would create an infinite recursion
unless you check that you are not in a subrequest by examining req.prev.

Grisha


More information about the Mod_python mailing list