Skip to content

Commit

Permalink
Fix add_remote_user when run without AuthenticationMiddleware. Fix #86 (
Browse files Browse the repository at this point in the history
#92)

* Fix add_remote_user when run without AuthenticationMiddleware. Fix #86

* Line wrap for flake8

* Suggested documentation tweak
  • Loading branch information
mccalluc authored and brianmay committed Aug 22, 2018
1 parent ddf67fc commit 6ba9b1d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions revproxy/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,16 @@ def get_request_headers(self):
"""Return request headers that will be sent to upstream.
The header REMOTE_USER is set to the current user
if the view's add_remote_user property is True
if AuthenticationMiddleware is enabled and
the view's add_remote_user property is True.
.. versionadded:: 0.9.8
"""
request_headers = self.get_proxy_request_headers(self.request)

if self.add_remote_user and self.request.user.is_active:
if (self.add_remote_user and hasattr(self.request, 'user')
and self.request.user.is_active):
request_headers['REMOTE_USER'] = self.request.user.get_username()
self.log.info("REMOTE_USER set")

Expand Down

0 comments on commit 6ba9b1d

Please sign in to comment.