def get_resources():
"""Return the resources of the authenticated user.
If authentication failed, this aborts the execution with
401 Unauthorized.
"""
#pprint(dict(request.headers))
header = request.environ.get('HTTP_AUTHORIZATION','')
if header:
print("Authorization:", header)
basic = request.auth
if basic:
username, password = basic
if passwords.get(username) != password:
abort(401, BASIC_ERROR)
else:
api_key = get_api_key()
if api_key is not None:
username = api_keys.get(api_key)
if username is None:
abort(401, API_KEY_ERROR)
else:
username = None
return _resources[username]
app.py 文件源码
python
阅读 19
收藏 0
点赞 0
评论 0
评论列表
文章目录