2005-11-29 18:26:07 +00:00
|
|
|
=========================================================
|
|
|
|
Authenticating against Django's user database from Apache
|
|
|
|
=========================================================
|
|
|
|
|
|
|
|
Since keeping multiple authentication databases in sync is a common problem when
|
|
|
|
dealing with Apache, you can configuring Apache to authenticate against Django's
|
2012-03-31 10:34:11 +00:00
|
|
|
:doc:`authentication system </topics/auth>` directly. This requires Apache
|
|
|
|
version >= 2.2 and mod_wsgi >= 2.0. For example, you could:
|
2005-11-29 18:26:07 +00:00
|
|
|
|
2011-10-14 00:12:01 +00:00
|
|
|
* Serve static/media files directly from Apache only to authenticated users.
|
2005-11-30 01:14:23 +00:00
|
|
|
|
2011-10-14 00:12:01 +00:00
|
|
|
* Authenticate access to a Subversion_ repository against Django users with
|
|
|
|
a certain permission.
|
2005-11-30 01:14:23 +00:00
|
|
|
|
2011-10-14 00:12:01 +00:00
|
|
|
* Allow certain users to connect to a WebDAV share created with mod_dav_.
|
2005-11-30 01:14:23 +00:00
|
|
|
|
2008-08-23 22:25:40 +00:00
|
|
|
.. _Subversion: http://subversion.tigris.org/
|
2012-03-31 10:34:11 +00:00
|
|
|
.. _mod_dav: http://httpd.apache.org/docs/2.2/mod/mod_dav.html
|
2008-08-23 22:25:40 +00:00
|
|
|
|
2005-11-29 18:26:07 +00:00
|
|
|
Configuring Apache
|
|
|
|
==================
|
|
|
|
|
|
|
|
To check against Django's authorization database from a Apache configuration
|
2012-03-31 10:34:11 +00:00
|
|
|
file, you'll need to set 'wsgi' as the value of ``AuthBasicProvider`` or
|
|
|
|
``AuthDigestProvider`` directive and then use the ``WSGIAuthUserScript``
|
|
|
|
directive to set the path to your authentification script:
|
2008-08-23 22:25:40 +00:00
|
|
|
|
|
|
|
.. code-block:: apache
|
2005-11-29 18:26:07 +00:00
|
|
|
|
|
|
|
<Location /example/>
|
2007-09-15 18:52:29 +00:00
|
|
|
AuthType Basic
|
2005-11-29 18:26:07 +00:00
|
|
|
AuthName "example.com"
|
2012-03-31 10:34:11 +00:00
|
|
|
AuthBasicProvider wsgi
|
|
|
|
WSGIAuthUserScript /usr/local/wsgi/scripts/auth.wsgi
|
2005-11-29 18:26:07 +00:00
|
|
|
Require valid-user
|
|
|
|
</Location>
|
2007-10-20 04:16:40 +00:00
|
|
|
|
2012-03-31 10:34:11 +00:00
|
|
|
Your auth.wsgi script will have to implement either a
|
|
|
|
``check_password(environ, user, password)`` function (for ``AuthBasicProvider``)
|
|
|
|
or a ``get_realm_hash(environ, user, realm)`` function (for ``AuthDigestProvider``).
|
2005-11-30 01:14:23 +00:00
|
|
|
|
2012-03-31 10:34:11 +00:00
|
|
|
See the `mod_wsgi documentation`_ for more details about the implementation
|
|
|
|
of such a solution.
|
2006-05-31 02:09:07 +00:00
|
|
|
|
2012-03-31 10:34:11 +00:00
|
|
|
.. _mod_wsgi documentation: http://code.google.com/p/modwsgi/wiki/AccessControlMechanisms#Apache_Authentication_Provider
|