Hello all,

I want to have an application settings modifying the project settings but 
it doesn't seems to work.

For development purpose I need to authenticate users against my application 
database. In Production
the authentication is done by Apache, it then sends the REMOTE_USER, 
correctly.

To realize the authentication in production, i am using one middleware, and 
one backend as found in
django documentation.

I would like to have only one setting in the project thesite/settings.py, a 
boolean called EXTERNAL_AUTH,
controling the content of AUTHENTICATION_BACKENDS and MIDDLEWARE_CLASSES.

The code modifying those two variables will stand in my application 
my/settings.py, It would then look like this

from django.conf import settings
if settings.EXTERNAL_AUTH == False:
    # Disabling standard login/logout.
    settings.LOGIN_REDIRECT_URL='/'
    settings.LOGIN_URL='/my/accounts/login/'
    settings.LOGOUT_URL='/my/accounts/logout/'
else:
    settings.AUTHENTICATION_BACKENDS = (
            ('my.backends.LDAPUserBackend', ) +
            settings.AUTHENTICATION_BACKENDS)

    # Insert LDAPUserMiddleware right after AuthenticationMiddleware
    index = settings.MIDDLEWARE_CLASSES.index(
            "django.contrib.auth.middleware.AuthenticationMiddleware")
    settings.MIDDLEWARE_CLASSES = (settings.MIDDLEWARE_CLASSES[:index+1] +
            ('my.backends.LDAPUserMiddleware', ) +
            settings.MIDDLEWARE_CLASSES[index+1:])

EXTERNAL_AUTH is used at different locations in my application, for example 
I use it to decide whether or not
I display the "change password" link.

When I start testing, toggling EXTERNAL_AUTH, the behavior is fuzzy. It 
inconsitently redirect me to the accounts/login
even if I'm authenticated through apache. I guess the middleware isn't 
called but when I raise an error, the debug page
contradicts this.

I'm a bit lost. Do you have any hint?

Regards,



-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to