1
0
mirror of https://github.com/Mailu/Mailu.git synced 2024-12-14 10:53:30 +02:00

define client_ip variable

(cherry picked from commit 34766602a8)
This commit is contained in:
Dominik Hebeler 2024-06-25 12:48:10 +02:00 committed by Mergify
parent 0d2630c47b
commit bca4fdffdb
2 changed files with 2 additions and 0 deletions

View File

@ -130,6 +130,7 @@ https://mailu.io/master/configuration.html#header-authentication-using-an-extern
def _proxy():
proxy_ip = flask.request.headers.get('X-Forwarded-By', flask.request.remote_addr)
ip = ipaddress.ip_address(proxy_ip)
client_ip = flask.request.headers.get('X-Real-IP', flask.request.remote_addr)
if not any(ip in cidr for cidr in app.config['PROXY_AUTH_WHITELIST']):
flask.current_app.logger.error(f'Login failed by proxy - not on whitelist: from {client_ip} through {flask.request.remote_addr}.')
return flask.abort(500, '%s is not on PROXY_AUTH_WHITELIST' % proxy_ip)

View File

@ -0,0 +1 @@
Define client_ip variable in _proxy method. Fixes server error when using proxy authentication