summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/release-notes/version-4.4.1.rst6
-rw-r--r--src/server/__init__.py15
-rw-r--r--tests/access.wsgi3
3 files changed, 24 insertions, 0 deletions
diff --git a/docs/release-notes/version-4.4.1.rst b/docs/release-notes/version-4.4.1.rst
index 5acd5f3..613edbe 100644
--- a/docs/release-notes/version-4.4.1.rst
+++ b/docs/release-notes/version-4.4.1.rst
@@ -29,3 +29,9 @@ served. One can still set specific handler types for different extensions
which may invoke a Python handler script, but there will be no global
fallback WSGI application for any URLs that do not map to static files. In
these cases a normal HTTP 404 response will be returned instead.
+
+3. Added ``--host-access-script`` option to ``mod_wsgi-express`` to allow
+a Python script to be provided which can control host access. This uses
+the ``WSGIAccessScript`` directive and the handler script should define an
+``allow_access(environ, host)`` function which returns ``True`` if access is
+allowed or ``False`` if blocked.
diff --git a/src/server/__init__.py b/src/server/__init__.py
index f5fb93d..7c6cfc9 100644
--- a/src/server/__init__.py
+++ b/src/server/__init__.py
@@ -550,6 +550,12 @@ DocumentRoot '%(document_root)s'
WSGIErrorOverride On
</IfDefine>
+<IfDefine WSGI_HOST_ACCESS>
+<Location />
+ WSGIAccessScript '%(host_access_script)s'
+</Location>
+</IfDefine>
+
<IfDefine WSGI_AUTH_USER>
<Location />
AuthType %(auth_type)s
@@ -1554,6 +1560,9 @@ option_list = (
'will be available at the /server-status sub URL. Defaults to '
'being disabled.'),
+ optparse.make_option('--host-access-script', metavar='SCRIPT-PATH',
+ default=None, help='Specify a Python script file for '
+ 'performing host access checks.'),
optparse.make_option('--auth-user-script', metavar='SCRIPT-PATH',
default=None, help='Specify a Python script file for '
'performing user authentication.'),
@@ -1823,6 +1832,10 @@ def _cmd_setup_server(command, args, options):
else:
options['entry_point'] = args[0]
+ if options['host_access_script']:
+ options['host_access_script'] = os.path.abspath(
+ options['host_access_script'])
+
if options['auth_user_script']:
options['auth_user_script'] = os.path.abspath(
options['auth_user_script'])
@@ -2174,6 +2187,8 @@ def _cmd_setup_server(command, args, options):
options['httpd_arguments_list'].append('-DWSGI_LISTENER_HOST')
if options['error_override']:
options['httpd_arguments_list'].append('-DWSGI_ERROR_OVERRIDE')
+ if options['host_access_script']:
+ options['httpd_arguments_list'].append('-DWSGI_HOST_ACCESS')
if options['auth_user_script']:
options['httpd_arguments_list'].append('-DWSGI_AUTH_USER')
if options['auth_group_script']:
diff --git a/tests/access.wsgi b/tests/access.wsgi
new file mode 100644
index 0000000..a0ebfc3
--- /dev/null
+++ b/tests/access.wsgi
@@ -0,0 +1,3 @@
+def allow_access(environ, host):
+ print environ, host
+ return True