api.py 文件源码

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

项目:YouPBX 作者: JoneXiong 项目源码 文件源码
def _validate_http_auth(self):
        """Verify http auth request with values in "Authorization" header
        """
        if not self.key or not self.secret:
            return True
        try:
            auth_type, encoded_auth_str = \
                request.headers['Authorization'].split(' ', 1)
            if auth_type == 'Basic':
                decoded_auth_str = base64.decodestring(encoded_auth_str)
                auth_id, auth_token = decoded_auth_str.split(':', 1)
                if auth_id == self.key and auth_token == self.secret:
                    return True
        except (KeyError, ValueError, TypeError):
            pass
        raise Unauthorized("HTTP Auth Failed")
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号