2
0

apache-auth.txt 1.8 KB

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