forked from wuhan2020/api-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtools.py
More file actions
21 lines (18 loc) · 648 Bytes
/
Copy pathtools.py
File metadata and controls
21 lines (18 loc) · 648 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import functools
import logging
from flask import make_response
logger = logging.getLogger(__file__)
def auth_token_wapper(token):
def _handler(func):
@functools.wraps(func)
def wrapper(request, *args, **kwargs):
http_token = request.META.get('HTTP_TOKEN')
logger.info(http_token)
if not http_token:
return make_response('403: HTTP_TOKEN is invalid')
else:
if token != http_token:
return make_response('403: HTTP_TOKEN is invalid')
return func(request, *args, **kwargs)
return wrapper
return _handler