From 29bfc9dd9dd6229f8283f359cb07ec4b2b3ca7ec Mon Sep 17 00:00:00 2001 From: Dimitri Huisman Date: Sat, 18 Mar 2023 08:16:30 +0000 Subject: [PATCH] Add fallback just in case X-Forwarded-By is empty. --- core/admin/mailu/sso/views/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/admin/mailu/sso/views/base.py b/core/admin/mailu/sso/views/base.py index bdc31889..80d1383c 100644 --- a/core/admin/mailu/sso/views/base.py +++ b/core/admin/mailu/sso/views/base.py @@ -92,7 +92,7 @@ def _has_usable_redirect(): https://mailu.io/master/configuration.html#header-authentication-using-an-external-proxy """ def _proxy(): - proxy_ip = flask.request.headers.get('X-Forwarded-By') + proxy_ip = flask.request.headers.get('X-Forwarded-By', flask.request.remote_addr) ip = ipaddress.ip_address(proxy_ip) if not any(ip in cidr for cidr in app.config['PROXY_AUTH_WHITELIST']): return flask.abort(500, '%s is not on PROXY_AUTH_WHITELIST' % proxy_ip)