Link config encryption backend logic with frontend (partially)

This commit is contained in:
Shreya 2021-05-28 18:42:46 +05:30 committed by VakarisZ
parent 495eb4c6a3
commit 308ae3e169
2 changed files with 12 additions and 4 deletions

View File

@ -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()

View File

@ -33,6 +33,9 @@ const ConfigExportModal = (props: Props) => {
})
}
)
.then(res => {
console.log(res.json());
})
}
return (