Skip to content

Commit 1242f83

Browse files
Merge branch 'release/4.3.0'
2 parents cc3c039 + ef1117a commit 1242f83

File tree

11 files changed

+1032
-75
lines changed

11 files changed

+1032
-75
lines changed

docs/release-notes/index.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ Release Notes
55
.. toctree::
66
:maxdepth: 2
77

8+
version-4.3.0.rst
9+
810
version-4.2.8.rst
911
version-4.2.7.rst
1012
version-4.2.6.rst

docs/release-notes/version-4.3.0.rst

Lines changed: 220 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,220 @@
1+
=============
2+
Version 4.3.0
3+
=============
4+
5+
Version 4.3.0 of mod_wsgi can be obtained from:
6+
7+
https://github.com/GrahamDumpleton/mod_wsgi/archive/4.3.0.tar.gz
8+
9+
Known Issues
10+
------------
11+
12+
1. The makefiles for building mod_wsgi on Windows are currently broken and
13+
need updating. As most new changes relate to mod_wsgi daemon mode, which is
14+
not supported under Windows, you should keep using the last available
15+
binary for version 3.X on Windows instead.
16+
17+
Bugs Fixed
18+
----------
19+
20+
1. Performing authorization using the ``WSGIAuthGroupScript`` was not
21+
working correctly on Apache 2.4 due to changes in how auth providers
22+
and authentication/authorization works. The result could be that a user
23+
could gain access to a resource even though they were not in the
24+
required group.
25+
26+
2. Under Apache 2.4, when creating the ``environ`` dictionary for
27+
passing into access/authentication/authorisation handlers, the behvaiour
28+
of Apache 2.4 as it pertained to the WSGI application, whereby it
29+
blocked the passing of any HTTP headers with a name which did not contain
30+
just alphanumerics or '-', was not being mirrored. This created the
31+
possibility of HTTP header spoofing in certain circumstances. Such headers
32+
are now being ignored.
33+
34+
3. When ``home`` option was used with ``WSGIDaemonProcess`` directive an
35+
empty string was added to ``sys.path``. This meant current working directory
36+
would be searched. This was fine so long as the current working directory
37+
wasn't changed, but if it was, it would no longer look in the home
38+
directory. Need to use the actual home directory instead.
39+
40+
4. Fixed Django management command integration so would work for versions
41+
of Django prior to 1.6 where ``BASE_DIR`` didn't exist in Django settings
42+
module.
43+
44+
Features Changed
45+
----------------
46+
47+
1. In Apache 2.4, any headers with a name which does not include only
48+
alphanumerics or '-' are blocked from being passed into a WSGI application
49+
when the CGI like WSGI ``environ`` dictionary is created. This is a
50+
mechanism to prevent header spoofing when there are multiple headers where
51+
the only difference is the use of non alphanumerics in a specific character
52+
position.
53+
54+
This protection mechanism from Apache 2.4 is now being restrospectively
55+
applied even when Apache 2.2 is being used and even though Apache itself
56+
doesn't do it. This may technically result in headers that were previously
57+
being passed, no longer being passed. The change is also technically
58+
against what the HTTP RFC says is allowed for HTTP header names, but such
59+
blocking would occur in Apache 2.4 anyway due to changes in Apache. It is
60+
also understood that other web servers such as nginx also perform the same
61+
type of blocking. Reliance on HTTP headers which use characters other
62+
than alphanumerics and '-' is therefore dubious as many servers will now
63+
discard them when needing to be passed into a system which requires the
64+
headers to be passed as CGI like variables such as is the case for WSGI.
65+
66+
2. In Apache 2.4, only ``wsgi-group`` is allowed when using the ``Require``
67+
directive for group authorisation. In prior Apache versions ``group`` would
68+
also be accepted and matched by the ``wsgi`` auth provider. The inability
69+
to use ``group`` is due to a change in Apache itself and not mod_wsgi. To
70+
avoid any issues going forward though, the mod_wsgi code will now no longer
71+
check for ``group`` even if for some reason Apache still decides to pass
72+
the authorisation check off to mod_wsgi even when it shouldn't.
73+
74+
New Features
75+
------------
76+
77+
1. The value of the ``REMOTE_USER`` variable for an authenticated user
78+
when user ``Basic`` authentication can now be overridden from an
79+
authentication handler specified using the ``WSGIAuthUserScript``. To
80+
override the name used to identify the user, instead of returning ``True``
81+
when indicating that the user is allowed, return the name to be used for
82+
that user as a string. That value will then be passed through in
83+
``REMOTE_USER`` in place of any original value::
84+
85+
def check_password(environ, user, password):
86+
if user == 'spy':
87+
if password == 'secret':
88+
return 'grumpy'
89+
return False
90+
return None
91+
92+
2. Added the ``--debug-mode`` option to ``mod_wsgi-express`` which results
93+
in Apache and the WSGI application being run in a single process which is
94+
left attached to stdin/stdout of the shell where the script was run. Only a
95+
single thread will be used to handle any requests.
96+
97+
This feature enables the ability to interactively debug a Python WSGI
98+
application using the Python debugger (``pdb``). The simplest way to
99+
break into the Python debugger is by adding to your WSGI application code::
100+
101+
import pdb; pdb.set_trace()
102+
103+
3. Added the ``--application-type`` option to ``mod_wsgi-express``. This
104+
defaults to ``script`` indicating that the target WSGI application provided
105+
to ``mod_wsgi-express`` is a WSGI script file defined by a relative or
106+
absolute file system path.
107+
108+
In addition to ``script``, it is also possible to supply for the application
109+
type ``module`` and ``paste``.
110+
111+
For the case of ``module``, the target WSGI application will be taken to
112+
reside in a Python module with the specified name. This module will be
113+
loaded using the standard Python module import system and so must reside
114+
on the Python module search path.
115+
116+
For the case of ``paste``, the target WSGI application will be taken to be
117+
a Paste deployment configuration file. In loading the Paste deployment
118+
configuration file, any WSGI application pipeline specified by the
119+
configuration will be constructed and the resulting top level WSGI
120+
application entry point returned used as the WSGI application.
121+
122+
Note that the code file for the WSGI script file, Python module, or Paste
123+
deployment configuration file, if modified, will all result in the WSGI
124+
application being automatically reloaded on the next web request.
125+
126+
4. Added the ``--auth-user-script`` and ``--auth-type`` options to
127+
``mod_wsgi-express`` to enable the hosted site to implement user
128+
authentication using either HTTP ``Basic`` or ``Digest`` authentication
129+
mechanisms. The ``check_password()`` or ``get_realm_hash()`` functions
130+
should follow the same form as if using the ``WSGIAuthUserScript`` direct
131+
with mod_wsgi when using manual configuration.
132+
133+
5. Added the ``--auth-group-script`` and ``--auth-group`` options to
134+
``mod_wsgi-express`` to enable group authorization to be performed using a
135+
group authorization script, in conjunction with a user authentication
136+
script. The ``groups_for_user()`` function should follow the same form as
137+
if using the ``WSGIAuthGroupScript`` direct with mod_wsgi when using manual
138+
configuration.
139+
140+
By default any users must be a member of the ``wsgi`` group. The name of
141+
this group though can be overridden using the ``--auth-group`` option.
142+
It is recommended that this be overridden rather than changing your own
143+
application to use the ``wsgi`` group.
144+
145+
6. Added the ``--directory-index`` option to ``mod_wsgi-express`` to enable
146+
a index resource to be added to the document root directory which would
147+
take precedence over the WSGI application for the root page for the site.
148+
149+
7. Added the ``--with-php5`` option to ``mod_wsgi-express`` to enable the
150+
concurrent hosting of a PHP web application in conjunction with the WSGI
151+
application. Due to the limitations of PHP, this is currently only
152+
supported if using prefork MPM.
153+
154+
8. Added the ``--server-name`` option to ``mod_wsgi-express``. When this is
155+
used and set to the host name for the web site, a virtual host will be
156+
created to ensure that the server only accepts web requests for that host
157+
name.
158+
159+
If the host name starts with ``www.`` then web requests will also be
160+
accepted against the parent domain, that is the host name without the
161+
``www.``, but those requests will be automatically redirected to the
162+
specified host name on the same port as that used for the original request.
163+
164+
When the ``--server-name`` option is being used, the ``--server-alias``
165+
option can also be specified, multiple times if need be, to setup alternate
166+
names for the web site on which web requests should also be accepted.
167+
Wildcard aliases may be used in the name if wishing to match multiple
168+
sub domains in one go.
169+
170+
If for some reason you do still need to be able to access the server via
171+
``localhost`` when a virtual host for a set server name is being used, you
172+
can supply the ``--allow-localhost`` option.
173+
174+
9. Added the ``--rotate-logs`` option to ``mod_wsgi-express`` to enable log
175+
file rotation. By default the error log and access log, if enabled, will be
176+
rotated when they reach 5MB in size. To change the size at which the log
177+
files will be rotated, use the ``--max-log-size`` option. If the
178+
``rotatelogs`` command is not being found properly, its location can be
179+
specified using the ``--rotatelogs-executable`` option.
180+
181+
10. Added the ``--ssl-port`` and ``--ssl-certificate`` options to
182+
``mod_wsgi-express``. When both are set, with the latter being the stub
183+
path for the SSL certificate ``.crt`` and ``.key`` file, then HTTPS
184+
requests will be handled over the designated SSL port.
185+
186+
When ``--https-only`` is supplied, any requests made over HTTP to the non
187+
SSL port will be automatically redirected so as to use a HTTPS connection
188+
over the SSL connection.
189+
190+
Note that if using the ``--allow-localhost`` option, redirection from a
191+
HTTP to HTTPS connection will not occur when access via ``localhost``.
192+
193+
11. Added the ``--setenv`` option to ``mod_wsgi-express`` to enable request
194+
specific name/value pairs to be added to the WSGI environ dictionary. The
195+
values are restricted to string values.
196+
197+
Also added a companion ``--passenv`` option to ``mod_wsgi-express`` to
198+
indicate the names of normal process environment variables which should
199+
be added to the per request WSGI environ dictionary.
200+
201+
12. Added the ``WSGIMapHEADToGET`` directive for overriding the previous
202+
behaviour of automatically mapping any ``HEAD`` request to a ``GET`` request
203+
when an Apache output filter was registered that may want to see the complete
204+
response in order to generate correct response headers.
205+
206+
The directive can be set to be either ``Auto`` (the default), ``On`` which
207+
will always map a ``HEAD`` to ``GET`` even if no output filters detected and
208+
``Off`` to always preserve the original request method type.
209+
210+
The original behaviour was to avoid problems with users trying to optimise
211+
for ``HEAD`` requests and then breaking caching mechanisms because the
212+
response headers for a ``HEAD`` request for a resource didn't match a ``GET``
213+
request against the same resource as required by HTTP.
214+
215+
If using mod_wsgi-express, the ``--map-head-to-get`` option can be used with
216+
the same values.
217+
218+
12. Added the ``--compress-responses`` option to ``mod_wsgi-express`` to
219+
enable compression of common text based responses such as plain text, HTML,
220+
XML, CSS and Javascript.

setup.py

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,17 @@ def get_apxs_config(query):
7575
else:
7676
HTTPD = PROGNAME
7777

78+
if os.path.exists(os.path.join(SBINDIR, 'rotatelogs')):
79+
ROTATELOGS = os.path.join(SBINDIR, 'rotatelogs')
80+
elif os.path.exists(os.path.join(BINDIR, 'rotatelogs')):
81+
ROTATELOGS = os.path.join(BINDIR, 'rotatelogs')
82+
else:
83+
ROTATELOGS = 'rotatelogs'
84+
7885
with open(os.path.join(os.path.dirname(__file__),
7986
'src/server/apxs_config.py'), 'w') as fp:
8087
print('HTTPD = "%s"' % HTTPD, file=fp)
88+
print('ROTATELOGS = "%s"' % ROTATELOGS, file=fp)
8189
print('BINDIR = "%s"' % BINDIR, file=fp)
8290
print('SBINDIR = "%s"' % SBINDIR, file=fp)
8391
print('PROGNAME = "%s"' % PROGNAME, file=fp)
@@ -122,13 +130,24 @@ def get_apxs_config(query):
122130

123131
os.environ['LD_RUN_PATH'] = LD_RUN_PATH
124132

125-
# If using Python 3.4, then minimum MacOS X version you can use is 10.8.
126-
# We have to force this with the compiler otherwise Python 3.4 sets it
127-
# to 10.6 which screws up Apache APR % formats for apr_time_t, which
128-
# breaks daemon mode queue time.
129-
130-
if sys.version_info >= (3, 4):
131-
os.environ['MACOSX_DEPLOYMENT_TARGET'] = '10.8'
133+
# On MacOS X, recent versions of Apple's Apache do not support compiling
134+
# Apache modules with a target older than 10.8. This is because it
135+
# screws up Apache APR % formats for apr_time_t, which breaks daemon
136+
# mode queue time. For the target to be 10.8 or newer for now if Python
137+
# installation supports older versions. This means that things will not
138+
# build for older MacOS X versions. Deal with these when they occur.
139+
140+
if sys.platform == 'darwin':
141+
target = os.environ.get('MACOSX_DEPLOYMENT_TARGET')
142+
if target is None:
143+
target = get_python_config('MACOSX_DEPLOYMENT_TARGET')
144+
145+
if target:
146+
target_version = tuple(map(int, target.split('.')))
147+
#assert target_version >= (10, 8), \
148+
# 'Minimum of 10.8 for MACOSX_DEPLOYMENT_TARGET'
149+
if target_version < (10, 8):
150+
os.environ['MACOSX_DEPLOYMENT_TARGET'] = '10.8'
132151

133152
# Now add the definitions to build everything.
134153

0 commit comments

Comments
 (0)