mirror of
https://github.com/Mailu/Mailu.git
synced 2025-03-05 14:55:20 +02:00
The Rate-limiter should run after the deny
This commit is contained in:
parent
3ccb6ff4b5
commit
f3c93212c6
@ -78,12 +78,6 @@ def handle_authentication(headers):
|
|||||||
# Authenticated user
|
# Authenticated user
|
||||||
elif method == "plain":
|
elif method == "plain":
|
||||||
is_valid_user = False
|
is_valid_user = False
|
||||||
if headers["Auth-Port"] == '25':
|
|
||||||
return {
|
|
||||||
"Auth-Status": "AUTH not supported",
|
|
||||||
"Auth-Error-Code": "502 5.5.1",
|
|
||||||
"Auth-Wait": 0
|
|
||||||
}
|
|
||||||
# According to RFC2616 section 3.7.1 and PEP 3333, HTTP headers should
|
# According to RFC2616 section 3.7.1 and PEP 3333, HTTP headers should
|
||||||
# be ASCII and are generally considered ISO8859-1. However when passing
|
# be ASCII and are generally considered ISO8859-1. However when passing
|
||||||
# the password, nginx does not transcode the input UTF string, thus
|
# the password, nginx does not transcode the input UTF string, thus
|
||||||
|
@ -11,6 +11,13 @@ def nginx_authentication():
|
|||||||
""" Main authentication endpoint for Nginx email server
|
""" Main authentication endpoint for Nginx email server
|
||||||
"""
|
"""
|
||||||
client_ip = flask.request.headers["Client-Ip"]
|
client_ip = flask.request.headers["Client-Ip"]
|
||||||
|
headers = flask.request.headers
|
||||||
|
if headers["Auth-Port"] == '25' and headers['Auth-Method'] == 'plain':
|
||||||
|
response = flask.Response()
|
||||||
|
response.headers['Auth-Status'] = 'AUTH not supported'
|
||||||
|
response.headers['Auth-Error-Code'] = '502 5.5.1'
|
||||||
|
utils.limiter.rate_limit_ip(client_ip)
|
||||||
|
return response
|
||||||
if utils.limiter.should_rate_limit_ip(client_ip):
|
if utils.limiter.should_rate_limit_ip(client_ip):
|
||||||
status, code = nginx.get_status(flask.request.headers['Auth-Protocol'], 'ratelimit')
|
status, code = nginx.get_status(flask.request.headers['Auth-Protocol'], 'ratelimit')
|
||||||
response = flask.Response()
|
response = flask.Response()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user