1
0
mirror of https://github.com/Mailu/Mailu.git synced 2024-12-14 10:53:30 +02:00
This commit is contained in:
Florent Daigniere 2021-10-16 09:36:49 +02:00
parent 068170c0ff
commit 2dd9ea1506

View File

@ -24,7 +24,7 @@ def nginx_authentication():
for key, value in headers.items():
response.headers[key] = str(value)
is_valid_user = False
if "Auth-User-Exists" in response.headers and response.headers["Auth-User-Exists"]:
if response.headers.get("Auth-User-Exists"):
username = response.headers["Auth-User"]
if utils.limiter.should_rate_limit_user(username, client_ip):
# FIXME could be done before handle_authentication()
@ -69,7 +69,7 @@ def user_authentication():
def basic_authentication():
""" Tries to authenticate using the Authorization header.
"""
client_ip = flask.request.headers["X-Real-IP"] if 'X-Real-IP' in flask.request.headers else flask.request.remote_addr
client_ip = flask.request.headers.get('X-Real-IP', flask.request.remote_addr)
if utils.limiter.should_rate_limit_ip(client_ip):
response = flask.Response(status=401)
response.headers["WWW-Authenticate"] = 'Basic realm="Authentication rate limit from one source exceeded"'