Skip to content

Add a middleware to set REMOTE_USER#9

Open
baxeico wants to merge 1 commit into
dellis23:masterfrom
baxeico:remote-user-middleware
Open

Add a middleware to set REMOTE_USER#9
baxeico wants to merge 1 commit into
dellis23:masterfrom
baxeico:remote-user-middleware

Conversation

@baxeico

@baxeico baxeico commented Feb 19, 2016

Copy link
Copy Markdown

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',
)

If user is authenticated in wordpress sets the user login in request.META['REMOTE_USER'], this enables Django remote user authentication mechanism https://docs.djangoproject.com/en/1.8/howto/auth-remote-user/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant