The ability to write low level handlers directly like that is not
likely to happen. There are sort of ways around this though.
Can you provide an example of what you are doing and perhaps explain
why something like mod_headers is insufficient?
Graham
http://code.google.com/p/modwsgi/wiki/AccessControlMechanisms
My understanding is that all DJango session state is stored in the
database, so it should be simultaneously accessible to the
authentication handler and the Django applications; it is just a matter
of configuring Django to share the session state between the two
applications. I don't know how to do it with DJango, but I imagine that
it is done the same way all other multiprocess configuration is done for
Django. See:
http://code.google.com/p/modwsgi/wiki/IntegrationWithDjango
"If any area of Django does give problems it may be its
support for sessions. This is because Django does not implement
any form of global session locking. That this is lacking though
should by rights also cause problems with multi process server
configurations as well as multithreaded servers."
http://code.djangoproject.com/ticket/1180
http://code.djangoproject.com/ticket/4531
> It could be that I'm asking too much, and I should just
> perform these checks in the applications themselves, whether
> they are PHP or whatever. However, it would be nice to only
> write the checks once and keep them all in one module that
> would protect several resources.
If you can find a way to get to get the session state sharing to work,
like above, then I think there is no problem. But, I think more a more
elaborate auth provider framework is too far out of scope for a WSGI
gateway. Graham has said that he would like mod_wsgi to become a kind of
Apache-WSGI fusion framework, so he probably disagrees. Perhaps, in
mod_wsgi 3.0, it will be possible to break out the core "pure WSGI"
functionality into a module seperate from the Apache-centric features.
- Brian
I see. You could probably use mod_headers to convert the cookie into an
"Authorization: DjangoCookie <cookie>" Authorization header, which would
presumably cause mod_wsgi to invoke your authentication script, which
can then parse the Authorization header to check for "Basic" vs
"DjangoCookie" and go from there.
- Brian
The problem is that once the Apache auth provider mechanism is
triggered the only option it provides is to allow access, or return
HTTP_UNAUTHORIZED. There is no way using an Apache auth provider to
trigger a redirect to some special page or return a different status.
A discussion was had on this of sorts against:
http://code.google.com/p/modwsgi/issues/detail?id=48&can=1
They didn't want cookie based sessions, but did want to change the
return status, albeit for authorisation and not authentication.
How auth providers and authorisation works is just how it works and it
is done in the same way that Apache does it. So, no real avenue for
trying to fudge things using it.
In the past I have thought about session based access controls across
disparate applications and static files and have implemented such
things for mod_python. These days I really don't know where this fits
into mod_wsgi since everyone seems more interested in just WSGI and
not the bigger picture of Apache as a web development platform. So,
some of my grander ideas seem to be falling by the way side.
There are probably going to be some big discussions in the coming
weeks on the list about where mod_wsgi goes after 2.0, so maybe hang
around, monitor that and speak up when we talk about what aspects of
what mod_python is capable of doing do we want to try and provide
equivalents for, or not as might be the case.
Graham
Unfortunately not, as you cant use the error document to force a
different status such as redirection. Browsers will not generally even
show any custom 401 error document as their immediate action is to pop
up the password dialog again.
Graham