app.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:schul_cloud_resources_server_tests 作者: schul-cloud 项目源码 文件源码
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]
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号