All WSGI implementations store the request headers in the environ
dictionary passed to the applicatoin. See
http://www.python.org/dev/peps/pep-0333/#environ-variables:
Variables corresponding to the client-supplied HTTP request headers
(i.e., variables whose names begin with "HTTP_"). The presence or
absence of these variables should correspond with the presence or
absence of the appropriate HTTP header in the request.
For example, value of the Accept-Language header is found using
environ['HTTP_ACCEPT_LANGUAGE'].
- Brian
http://code.google.com/p/modwsgi/wiki/ConfigurationGuidelines
and description of WSGIPassAuthorization directive in:
http://code.google.com/p/modwsgi/wiki/ConfigurationDirectives
Graham
Can this be made to work with .htaccess?
- Brian
No.
If one allowed that, then one would for example in a corporate setting
where HTTP auth was used across a whole web site, allow any individual
user who may have ability to run WSGI stuff to then collect the logins
and passwords of his work mates. For reasons like that it is
explicitly only allowed to be set from main Apache configuration where
the system administrator has control and can make the decision if
someone is trusted and should be able to see the passwords.
Being extra secure like this seems to be the more prudent option.
Graham
Whether .htaccess is slow really depends on what you are doing and how
you are using it. In the scheme of things, a roughly five percent
reduction through prudent use of .htaccess files may be quite
acceptable when you balance it against the ability to dynamically
change the configuration of the application without having to restart
the whole of Apache.
I vaguely remember there being a comment against this recent Python
and PHP conversation brought up by Ian Bicking and others which
suggested that one of the major Internet web sites still used
.htaccess files for this exact reason.
Also, that five percent figure I give is based on looking at what one
can achieve as maximum throughput for a site when the application is
doing the least possible. In this case I used the mod_wsgi performance
figures as a guide.
http://code.google.com/p/modwsgi/wiki/PerformanceEstimates
When you consider though that the WSGI application and any database
access is going to cause your request through to drop quite a fair bit
of the theoretical maximum, that five percent actually drops down to
be a much much lower percentage when you look at the much longer
request time of a complex application.
So, my feeling is that .htaccess files are probably not as bad as many
people make out, provided that is that they aren't abused and you have
deep directory hierarchies with lots of .htaccess file spread all
other the place.
Graham
Can't it be conditional based on "AllowOverride AuthConfig" or a new
AllowOverride option?
This isn't a valid (effective) security mechanism when mod_rewrite is
active. See http://www.rittau.org/blog/20061119-00,
http://codex.gallery2.org/Gallery2:Modules:httpauth#Authorization_Header
, and other sources:
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule ^(.*)$ $1 [e=HTTP_AUTHORIZATION:%1]
Misusing mod_rewrite like this is more likely to result in a security
breach than a straightforward mechanism.
There are a lot of (Python) web applications that are implementing new
authentication protocols like OpenID, or emulating the Amazon.com Web
Services or Google Auth authentication mechanisms. If you want these
applications to be deployable behind mod_wsgi in a shared web hosting
environment, then they need to be able to process the Authorization
header.
- Brian
One can't extend AllowOverride beyond the fixed values it takes now. I
did think about using AuthConfig to allow it in .htaccess but at the
time decided to just err on side of caution and defer making that
decision.
The problem I had at the time was that I really wanted a way to
optionally allow WSGIProcessGroup and WSGIApplicationGroup, as well as
WSGIPassAuthorization to be defined in .htaccess file. The
AllowOverride couldn't be extended and wasn't too keen on adding a
WSGIAllowOverride directive equivalent just for mod_wsgi.
To get around WSGIProcessGroup and WSGIApplicationGroup the solution
was to allow in main configuration:
SetEnv APPLICATION_GROUP %{GLOBAL}
WSGIApplicationGroup %{ENV:APPLICATION_GROUP}
That way if user has FileInfo override they could say:
SetEnv APPLICATION_GROUP xyz
as a way of overriding it. To allow that did require it to be setup in
main configuration first.
So I had a solution for those two directives at least. I didn't then
allow WSGIPassAuthorization to be controlled by AuthConfig as saw them
as allowing how auth information was used, but didn't in any other
cases, eg, CGI, allow it to be passed through to a script of some
form. But then, the CGI cases is more problematic because the
information actually appears in environment variables which are more
easily accessed.
> This isn't a valid (effective) security mechanism when mod_rewrite is
> active. See http://www.rittau.org/blog/20061119-00,
> http://codex.gallery2.org/Gallery2:Modules:httpauth#Authorization_Header
> , and other sources:
>
> RewriteEngine on
> RewriteBase /
> RewriteCond %{HTTP:Authorization} ^(.*)
> RewriteRule ^(.*)$ $1 [e=HTTP_AUTHORIZATION:%1]
>
> Misusing mod_rewrite like this is more likely to result in a security
> breach than a straightforward mechanism.
Yeah, well I didn't think of that one. :-(
One can't even stop this through mod_wsgi always ensuring that
HTTP_AUTHORISATION is deleted from environment when
WSGIPassAuthorization not set. This is because user could just pass it
through a variable of another name.
Since that hack is available when FileInfo is allowed, can't see any
downside then of allowing WSGIPassAuthorization when AuthConfig is
allowed, as less likely that AuthConfig would be allowed anyway.
> There are a lot of (Python) web applications that are implementing new
> authentication protocols like OpenID, or emulating the Amazon.com Web
> Services or Google Auth authentication mechanisms. If you want these
> applications to be deployable behind mod_wsgi in a shared web hosting
> environment, then they need to be able to process the Authorization
> header.
The way I saw it was that the documentation for shared web hosting
would explain setting WSGIPassAuthorization to enable passing of the
information if site configurations were always such that only one user
own the site. In other words, still wanted it to be a conscious
decision of the person setting up the box after they understood the
consequences.
Graham
--
You received this message because you are subscribed to the Google Groups "modwsgi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to modwsgi+u...@googlegroups.com.
To post to this group, send email to mod...@googlegroups.com.
Visit this group at http://groups.google.com/group/modwsgi.
For more options, visit https://groups.google.com/d/optout.