fixuphandler with mod_wsgi

27 views
Skip to first unread message

Dominik Ruf

unread,
Sep 1, 2011, 12:21:22 PM9/1/11
to mod...@googlegroups.com
Hi,

I currently use a mod_python fixuphandler to set an environment variable USER_EMAIL.
The value for this variable I get from a ldap request based on the user name that had been set by an apache auth module.

def fixuphandler(req):
    remote_user = req.user.split('\\')[-1]
    l = ldap.initialize("ldap://myserver:389")
    l.simple_bind_s("","")
    r = l.search_s("o=myorg", ldap.SCOPE_SUBTREE, "uid=%s" % remote_user)

    req.subprocess_env['USER_EMAIL'] = r[0][1]['mail'][0]
    return apache.OK


Since mod_python is dead (or dying) I am wondering if this is possible with mod_wsgi.

cheers
Dominik

Graham Dumpleton

unread,
Sep 1, 2011, 8:36:37 PM9/1/11
to mod...@googlegroups.com
What is ultimately seeing the USER_EMAIL variable. A Python web
application, a PHP application, a CGI script or something else?

What you want to do is possible but only with help of a separate
package to mod_wsgi which doesn't make it necessarily practical at the
moment, especially since there has never been enough interest in the
separate package to make it worthwhile maintaining it.

Graham

> --
> You received this message because you are subscribed to the Google Groups
> "modwsgi" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/modwsgi/-/yooYURHwJmMJ.
> To post to this group, send email to mod...@googlegroups.com.
> To unsubscribe from this group, send email to
> modwsgi+u...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/modwsgi?hl=en.
>

Dominik Ruf

unread,
Sep 2, 2011, 3:45:25 AM9/2/11
to mod...@googlegroups.com
The USER_EMAIL variable is used by a CGI application. (bugzilla to be exact)
What kin of additional package do I need.
I'm not sure if I understand this correctly, does such a package already exist?

Graham Dumpleton

unread,
Sep 2, 2011, 3:57:20 AM9/2/11
to mod...@googlegroups.com

I experimented with Apache Python bindings with SWIG. Results at:

https://bitbucket.org/grahamdumpleton/apswigpy/wiki/Home

There is a directive in mod_wsgi called:

WSGIPassApacheRequest On

which passes reference to AAA function in mod_wsgi:

http://code.google.com/p/modwsgi/wiki/AccessControlMechanisms

You can then do something like:

import apache.httpd
r = apache.httpd.request_rec(environ['apache.request_rec'])
r.subprocess_env['USER_EMAIL'] = 'asdasads'

The AAA functions though service a specific purpose and can't be
hooked for arbitrary purposes.

You might manage it with allow_access() function so long as that isn't
too early.

The apswigpy isn't really supported as there wasn't any interest in it.

Graham

Dominik Ruf

unread,
Sep 2, 2011, 4:48:52 AM9/2/11
to mod...@googlegroups.com
OK thanks I'll give it a shot.
Reply all
Reply to author
Forward
0 new messages