django-wordpress-auth icon indicating copy to clipboard operation
django-wordpress-auth copied to clipboard

Add a middleware to set REMOTE_USER

Open baxeico opened this issue 9 years ago • 0 comments

If user is authenticated in wordpress sets the user login in request.META['REMOTE_USER'], this enables Django remote user authentication mechanism. As a result you'll have a regular request.user available in your views with all the usual methods to check permissions against Django permission system.

To enable this behavior in Django, set these values in settings.py:

MIDDLEWARE_CLASSES = (
    ...
    'wordpress_auth.middleware.WordPressAuthMiddleware',
    'wordpress_auth.middleware.WordPressRemoteUserMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.auth.middleware.RemoteUserMiddleware',
    ...
)

AUTHENTICATION_BACKENDS = (
    'django.contrib.auth.backends.RemoteUserBackend',
)

baxeico avatar Feb 19 '16 10:02 baxeico