diff --git a/monkey/monkey_island/cc/resources/configuration_export.py b/monkey/monkey_island/cc/resources/configuration_export.py index 00dc00fd0..2b759cf76 100644 --- a/monkey/monkey_island/cc/resources/configuration_export.py +++ b/monkey/monkey_island/cc/resources/configuration_export.py @@ -1,7 +1,7 @@ import json import flask_restful -from flask import jsonify, request +from flask import request from monkey_island.cc.resources.auth.auth import jwt_required from monkey_island.cc.services.config import ConfigService @@ -11,13 +11,18 @@ from monkey_island.cc.services.utils.config_encryption import encrypt_config class ConfigurationExport(flask_restful.Resource): @jwt_required def get(self): - return jsonify(encrypted_config=self.encrypted_config) + return {"encrypted_config": self.config_to_return} @jwt_required def post(self): - password = json.loads(request.data)["password"] + data = json.loads(request.data) + should_encrypt = data["should_encrypt"] + plaintext_config = ConfigService.get_config() - self.encrypted_config = encrypt_config(plaintext_config, password) + self.config_to_return = plaintext_config + if should_encrypt: + password = data["password"] + self.config_to_return = encrypt_config(plaintext_config, password) return self.get() diff --git a/monkey/monkey_island/cc/ui/src/components/configuration-components/ExportConfigModal.tsx b/monkey/monkey_island/cc/ui/src/components/configuration-components/ExportConfigModal.tsx index d6d84d14e..7e9458979 100644 --- a/monkey/monkey_island/cc/ui/src/components/configuration-components/ExportConfigModal.tsx +++ b/monkey/monkey_island/cc/ui/src/components/configuration-components/ExportConfigModal.tsx @@ -33,6 +33,9 @@ const ConfigExportModal = (props: Props) => { }) } ) + .then(res => { + console.log(res.json()); + }) } return (