mirror of
https://github.com/Mailu/Mailu.git
synced 2025-01-20 03:29:50 +02:00
Ensure we have an api_token
This commit is contained in:
parent
4837a05c71
commit
2db75921a2
@ -25,7 +25,7 @@ def api_token_authorization(func):
|
||||
abort(429, 'Too many attempts from your IP (rate-limit)' )
|
||||
if not request.headers.get('Authorization'):
|
||||
abort(401, 'A valid Authorization header is mandatory')
|
||||
if (not hmac.compare_digest(request.headers.get('Authorization').removeprefix('Bearer '), v1.api_token)):
|
||||
if len(v1.api_token) < 4 or not hmac.compare_digest(request.headers.get('Authorization').removeprefix('Bearer '), v1.api_token):
|
||||
utils.limiter.rate_limit_ip(client_ip)
|
||||
flask.current_app.logger.warn(f'Invalid API token provided by {client_ip}.')
|
||||
abort(403, 'Invalid API token')
|
||||
|
Loading…
x
Reference in New Issue
Block a user