diff --git a/monkey/monkey_island/cc/app.py b/monkey/monkey_island/cc/app.py index 408839b6c..df8497f65 100644 --- a/monkey/monkey_island/cc/app.py +++ b/monkey/monkey_island/cc/app.py @@ -28,6 +28,9 @@ from monkey_island.cc.resources.blackbox.monkey_blackbox_endpoint import MonkeyB from monkey_island.cc.resources.blackbox.telemetry_blackbox_endpoint import ( TelemetryBlackboxEndpoint, ) +from monkey_island.cc.resources.credentials.configured_propagation_credentials import ( + ConfiguredPropagationCredentials, +) from monkey_island.cc.resources.edge import Edge from monkey_island.cc.resources.exploitations.manual_exploitation import ManualExploitation from monkey_island.cc.resources.exploitations.monkey_exploitation import MonkeyExploitation @@ -185,6 +188,8 @@ def init_restful_endpoints(api: FlaskDIWrapper): api.add_resource(FileUpload) api.add_resource(PropagationCredentials) + api.add_resource(ConfiguredPropagationCredentials) + api.add_resource(RemoteRun) api.add_resource(VersionUpdate) api.add_resource(StopAgentCheck) diff --git a/monkey/monkey_island/cc/resources/credentials/configured_propagation_credentials.py b/monkey/monkey_island/cc/resources/credentials/configured_propagation_credentials.py new file mode 100644 index 000000000..0794e979c --- /dev/null +++ b/monkey/monkey_island/cc/resources/credentials/configured_propagation_credentials.py @@ -0,0 +1,27 @@ +import logging + +from flask import jsonify, request + +from common.credentials import Credentials +from monkey_island.cc.repository import ICredentialsRepository +from monkey_island.cc.resources.AbstractResource import AbstractResource + +logger = logging.getLogger(__name__) + + +class ConfiguredPropagationCredentials(AbstractResource): + # API Spec: Resource name should be plural + urls = ["/api/propagation-credentials/configured"] + + def __init__(self, credentials_repository: ICredentialsRepository): + self._credentials_repository = credentials_repository + + def get(self): + return jsonify(self._credentials_repository.get_configured_credentials()) + + def post(self): + credentials = Credentials.from_mapping(request.json) + self._credentials_repository.save_configured_credentials(credentials) + + def delete(self): + self._credentials_repository.remove_configured_credentials()