forked from p15670423/monkey
Link config encryption backend logic with frontend (partially)
This commit is contained in:
parent
495eb4c6a3
commit
308ae3e169
|
@ -1,7 +1,7 @@
|
||||||
import json
|
import json
|
||||||
|
|
||||||
import flask_restful
|
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.resources.auth.auth import jwt_required
|
||||||
from monkey_island.cc.services.config import ConfigService
|
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):
|
class ConfigurationExport(flask_restful.Resource):
|
||||||
@jwt_required
|
@jwt_required
|
||||||
def get(self):
|
def get(self):
|
||||||
return jsonify(encrypted_config=self.encrypted_config)
|
return {"encrypted_config": self.config_to_return}
|
||||||
|
|
||||||
@jwt_required
|
@jwt_required
|
||||||
def post(self):
|
def post(self):
|
||||||
password = json.loads(request.data)["password"]
|
data = json.loads(request.data)
|
||||||
|
should_encrypt = data["should_encrypt"]
|
||||||
|
|
||||||
plaintext_config = ConfigService.get_config()
|
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()
|
return self.get()
|
||||||
|
|
|
@ -33,6 +33,9 @@ const ConfigExportModal = (props: Props) => {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
.then(res => {
|
||||||
|
console.log(res.json());
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
Loading…
Reference in New Issue