mirror of
https://github.com/Mailu/Mailu.git
synced 2024-12-14 10:53:30 +02:00
Merge pull request #513 from mprihoda/feature/better-ratelimit-error
Return correct status codes from auth rate limiter failure.
This commit is contained in:
commit
313b79538e
@ -1,3 +1,5 @@
|
|||||||
|
from flask_limiter import RateLimitExceeded
|
||||||
|
|
||||||
from mailu import limiter
|
from mailu import limiter
|
||||||
|
|
||||||
import socket
|
import socket
|
||||||
@ -6,6 +8,14 @@ import flask
|
|||||||
|
|
||||||
internal = flask.Blueprint('internal', __name__)
|
internal = flask.Blueprint('internal', __name__)
|
||||||
|
|
||||||
|
@internal.app_errorhandler(RateLimitExceeded)
|
||||||
|
def rate_limit_handler(e):
|
||||||
|
response = flask.Response()
|
||||||
|
response.headers['Auth-Status'] = 'Authentication rate limit from one source exceeded'
|
||||||
|
response.headers['Auth-Error-Code'] = '451 4.3.2'
|
||||||
|
if int(flask.request.headers['Auth-Login-Attempt']) < 10:
|
||||||
|
response.headers['Auth-Wait'] = '3'
|
||||||
|
return response
|
||||||
|
|
||||||
@limiter.request_filter
|
@limiter.request_filter
|
||||||
def whitelist_webmail():
|
def whitelist_webmail():
|
||||||
|
Loading…
Reference in New Issue
Block a user