review fixes
This commit is contained in:
1 parent
495d99fbe9
commit
7726e5c04e
2 files changed
+15
-12
No files matched your search
@@ -65,8 +65,8 @@ Use the following settings to enable access control:
|
||||
# Whether to trust remote user headers. If you have setup authentication in front of
|
||||
# OctoPrint and the user names you use there match OctoPrint accounts, by setting this to true users will
|
||||
# be logged into OctoPrint as the user provided in the header. Your should ONLY ENABLE THIS if your
|
||||
# OctoPrint instance is only accessible through a connection locked down through an authenitating reverse proxy!
|
||||
trustBasicAuthentication: false
|
||||
# OctoPrint instance is only accessible through a connection locked down through an authenticating reverse proxy!
|
||||
trustRemoteUser: false
|
||||
|
||||
# Header used by the reverse proxy to convey the authenticated user.
|
||||
remoteUserHeader: REMOTE_USER
|
||||
|
||||
@@ -147,14 +147,15 @@ def load_user(id):
|
||||
|
||||
return None
|
||||
|
||||
def load_user_from_request_chain(request):
|
||||
user = None
|
||||
if g.get("trust_basic_authentication"):
|
||||
user = util.get_user_for_authorization_header(request.headers.get('Authorization'))
|
||||
|
||||
def load_remote_user_from_request(request):
|
||||
return util.get_user_for_remote_user_header(request)
|
||||
|
||||
|
||||
def load_user_from_request(request):
|
||||
return util.get_user_for_authorization_header(request.headers.get('Authorization'))
|
||||
if user is None and g.get("trust_remote_user"):
|
||||
user = util.get_user_for_remote_user_header(request)
|
||||
|
||||
return user
|
||||
|
||||
def unauthorized_user():
|
||||
from flask import abort
|
||||
@@ -1606,11 +1607,13 @@ class Server(object):
|
||||
|
||||
# login users authenticated by basic auth
|
||||
if self._settings.get(["accessControl", "trustBasicAuthentication"]):
|
||||
loginManager.request_callback = load_user_from_request
|
||||
g.trust_basic_authentication = True
|
||||
|
||||
# Login via REMOTE_USER header
|
||||
if self._settings.get(["accessControl", "useRemoteUser"]):
|
||||
loginManager.request_callback = load_remote_user_from_request
|
||||
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
|
||||
|
||||
if not userManager.enabled:
|
||||
loginManager.anonymous_user = users.DummyUser
|
||||
|
||||
Reference in new issue
Block a user