♻ Slight refactoring...

This commit is contained in:
Gina Häußge committed 2019-05-09 15:40:51 +02:00
1 parent 6711813fef
commit b46a66caa8
1 file changed
+7 -13
+7 -13
View File
@@ -147,12 +147,15 @@ def load_user(id):
return None
def load_user_from_request_chain(request):
def load_user_from_request(request):
user = None
if g.get("trust_basic_authentication"):
if settings().getBoolean(["accessControl", "trustBasicAuthentication"]):
# Basic Authentication?
user = util.get_user_for_authorization_header(request.headers.get('Authorization'))
if user is None and g.get("trust_remote_user"):
if settings().getBoolean(["accessControl", "trustRemoteUser"]):
# Remote user header?
user = util.get_user_for_remote_user_header(request)
return user
@@ -1604,16 +1607,7 @@ class Server(object):
loginManager.user_callback = load_user
loginManager.unauthorized_callback = unauthorized_user
# login users authenticated by basic auth
if self._settings.get(["accessControl", "trustBasicAuthentication"]):
g.trust_basic_authentication = True
if self._settings.get(["accessControl", "trustRemoteUser"]):
g.trust_remote_user = True
if g.get("trust_basic_authentication") or g.get("trust_remote_user"):
loginManager.request_callback = load_user_from_request_chain
loginManager.request_callback = load_user_from_request
if not userManager.enabled:
loginManager.anonymous_user = users.DummyUser