views:

611

answers:

2

I want to give users access to WebDav using Apache, but I want to autenticate them first and give each user access to a specific folder. All authentication must be done against a Django-based database. I can get the Django-authentication working myself, but I need help with the part where I authenticate each user and provide them with a dedicated webdav user-specific area.

Any hints?

A: 

You might find that the apache mod_authn_dbd module gives you what you want. This module lets apache check an SQL database for authentication and authorization. You would use this directive in the <Location>, <Directory> (etc) area that you are trying to protect:

<Directory /usr/www/myhost/private>
    # other config ere
    # mod_authn_dbd SQL query to authenticate a user
    AuthDBDUserPWQuery \
         "SELECT password FROM authn WHERE user = %s"
 </Directory>

Strictly speaking, this means you're authenticating against Django's database, not against the Django app itself. Note that you have full control over the query, so you CAN combine it with other parameters in any tables to make sure the user is in good standing, or in certain groups, or whatever, before allowing the authentication.

You may need to fuss around a bit to make sure the hashing mechanisms used are the same in both apache and django.

If this doesn't suit, consider moving your authentication out of the django database into, say, an LDAP server. With a custom authentication backend (there are existing LDAP implementations for django out there), django will happily use LDAP... and LDAP auth/auth support in Apache is quite robust.

Jarret Hardie
A: 

I know this question is old, but just as an addition... If you are using mod_python, you may also be interested in "Authenticating against Django’s user database from Apache" section of Django documentation.

drdaeman