feat: build wahrwelt A/D toolkit
This commit is contained in:
1 parent
303438d206
commit
653924d8c6
564 files changed
+36310
-49998
No files matched your search
@@ -0,0 +1,24 @@
|
||||
import hmac
|
||||
from functools import wraps
|
||||
|
||||
from flask import request, abort
|
||||
|
||||
from config import CONFIG
|
||||
|
||||
|
||||
def auth_required(f):
|
||||
@wraps(f)
|
||||
def decorated(*args, **kwargs):
|
||||
config = CONFIG
|
||||
auth = request.headers.get('Authorization') or request.headers.get('X-Token') or ''
|
||||
try:
|
||||
supplied = auth.encode('ascii')
|
||||
except UnicodeEncodeError:
|
||||
abort(403)
|
||||
expected = config['SERVER_PASSWORD'].encode('ascii')
|
||||
if not hmac.compare_digest(supplied, expected):
|
||||
abort(403)
|
||||
|
||||
return f(*args, **kwargs)
|
||||
|
||||
return decorated
|
||||
Reference in new issue
Block a user