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')
评论列表
文章目录