Ensure that users should be able to modify the REMOTE_USER environment

variable as per their environment by introducing the new config parameter
WEBSERVER_REMOTE_USER.

Fixes #6953
This commit is contained in:
Khushboo Vashi
2021-11-10 15:38:41 +05:30
committed by Akshay Joshi
parent 9479f0e632
commit d4697e8f1c
4 changed files with 16 additions and 1 deletions

View File

@@ -736,6 +736,13 @@ OAUTH2_AUTO_CREATE_USER = True
WEBSERVER_AUTO_CREATE_USER = True
# REMOTE_USER variable will be used to check the environment variable
# is set or not first, if not available,
# request header will be checked for the same.
# Possible values: REMOTE_USER, HTTP_X_FORWARDED_USER, X-Forwarded-User
WEBSERVER_REMOTE_USER = 'REMOTE_USER'
##########################################################################
# PSQL tool settings
##########################################################################

View File

@@ -77,7 +77,11 @@ class WebserverAuthentication(BaseAuthentication):
return True
def get_user(self):
return request.environ.get('REMOTE_USER')
username = request.environ.get(config.WEBSERVER_REMOTE_USER)
if not username:
# One more try to get the Remote User from the hearders
username = request.headers.get(config.WEBSERVER_REMOTE_USER)
return username
def authenticate(self, form):
username = self.get_user()