xvp_proxy.py 文件源码

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

项目:Trusted-Platform-Module-nova 作者: BU-NU-CLOUD-SP16 项目源码 文件源码
def __call__(self, environ, start_response):
        try:
            req = webob.Request(environ)
            LOG.info(_LI("Request: %s"), req)
            token = req.params.get('token')
            if not token:
                LOG.info(_LI("Request made with missing token: %s"), req)
                start_response('400 Invalid Request',
                               [('content-type', 'text/html')])
                return "Invalid Request"

            ctxt = context.get_admin_context()
            api = consoleauth_rpcapi.ConsoleAuthAPI()
            connect_info = api.check_token(ctxt, token)

            if not connect_info:
                LOG.info(_LI("Request made with invalid token: %s"), req)
                start_response('401 Not Authorized',
                               [('content-type', 'text/html')])
                return "Not Authorized"

            return self.proxy_connection(req, connect_info, start_response)
        except Exception as e:
            LOG.info(_LI("Unexpected error: %s"), e)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号