vmcp.py 文件源码

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

项目:FRG-Crowdsourcing 作者: 97amarnathk 项目源码 文件源码
def get(self, oid=None):
        """Return signed VMCP for CernVM requests."""
        if current_app.config.get('VMCP_KEY') is None:
            message = "The server is not configured properly, contact the admins"
            error = self._format_error(status_code=501, message=message)
            return Response(json.dumps(error), status=error['status_code'],
                            mimetype='application/json')

        pkey = (current_app.root_path + '/../keys/' +
                current_app.config.get('VMCP_KEY'))
        if not os.path.exists(pkey):
            message = "The server is not configured properly (private key is missing), contact the admins"
            error = self._format_error(status_code=501, message=message)
            return Response(json.dumps(error), status=error['status_code'],
                            mimetype='application/json')

        if request.args.get('cvm_salt') is None:
            message = "cvm_salt parameter is missing"
            error = self._format_error(status_code=415, message=message)
            return Response(json.dumps(error), status=error['status_code'],
                            mimetype='application/json')

        salt = request.args.get('cvm_salt')
        data = request.args.copy()
        signed_data = pybossa.vmcp.sign(data, salt, pkey)
        return Response(json.dumps(signed_data), 200, mimetype='application/json')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号