diff --git a/monkey/monkey_island/cc/resources/propagation_credentials.py b/monkey/monkey_island/cc/resources/propagation_credentials.py index 978569cee..2342d0f37 100644 --- a/monkey/monkey_island/cc/resources/propagation_credentials.py +++ b/monkey/monkey_island/cc/resources/propagation_credentials.py @@ -42,13 +42,20 @@ class PropagationCredentials(AbstractResource): return {}, HTTPStatus.NO_CONTENT - def patch(self, collection=None): - if collection != _configured_collection: - return {}, HTTPStatus.METHOD_NOT_ALLOWED - + def put(self, collection=None): credentials = [Credentials.from_mapping(c) for c in request.json] - self._credentials_repository.remove_configured_credentials() - self._credentials_repository.save_configured_credentials(credentials) + + if collection == _configured_collection: + self._credentials_repository.remove_configured_credentials() + self._credentials_repository.save_configured_credentials(credentials) + elif collection == _stolen_collection: + self._credentials_repository.remove_stolen_credentials() + self._credentials_repository.save_stolen_credentials(credentials) + elif collection is None: + return {}, HTTPStatus.METHOD_NOT_ALLOWED + else: + return {}, HTTPStatus.NOT_FOUND + return {}, HTTPStatus.NO_CONTENT def delete(self, collection=None): diff --git a/monkey/monkey_island/cc/ui/src/components/configuration-components/ImportConfigModal.tsx b/monkey/monkey_island/cc/ui/src/components/configuration-components/ImportConfigModal.tsx index b56ce64a8..0af9baeb2 100644 --- a/monkey/monkey_island/cc/ui/src/components/configuration-components/ImportConfigModal.tsx +++ b/monkey/monkey_island/cc/ui/src/components/configuration-components/ImportConfigModal.tsx @@ -42,7 +42,6 @@ const ConfigImportModal = (props: Props) => { useEffect(() => { if (configContents !== null && configCredentials !== null) { - console.log("useEffect was called"); tryImport(); } }, [configContents, configCredentials, unsafeOptionsVerified]) @@ -80,7 +79,7 @@ const ConfigImportModal = (props: Props) => { console.log(credentials); authComponent.authFetch(credentialsEndpoint, { - method: 'PATCH', + method: 'PUT', headers: {'Content-Type': 'application/json'}, body: JSON.stringify(credentials) } diff --git a/monkey/monkey_island/cc/ui/src/components/pages/ConfigurePage.js b/monkey/monkey_island/cc/ui/src/components/pages/ConfigurePage.js index 48936ef66..66e9cced1 100644 --- a/monkey/monkey_island/cc/ui/src/components/pages/ConfigurePage.js +++ b/monkey/monkey_island/cc/ui/src/components/pages/ConfigurePage.js @@ -300,7 +300,7 @@ class ConfigurePageComponent extends AuthComponent { return ( this.authFetch(CONFIGURED_PROPAGATION_CREDENTIALS_URL, { - method: 'PATCH', + method: 'PUT', headers: {'Content-Type': 'application/json'}, body: JSON.stringify(formatCredentialsForIsland(this.state.credentials)) })