diff --git a/monkey/monkey_island/cc/environment/__init__.py b/monkey/monkey_island/cc/environment/__init__.py index 70fb775c5..0aeac1fde 100644 --- a/monkey/monkey_island/cc/environment/__init__.py +++ b/monkey/monkey_island/cc/environment/__init__.py @@ -23,34 +23,6 @@ class Environment(object, metaclass=ABCMeta): self._config = config self._testing = False # Assume env is not for unit testing. - def get_user(self): - return self._config.user_creds - - def needs_registration(self) -> bool: - try: - needs_registration = self._try_needs_registration() - return needs_registration - except (AlreadyRegisteredError) as e: - logger.info(e) - return False - - def try_add_user(self, credentials: UserCreds): - if not credentials: - raise InvalidRegistrationCredentialsError("Missing part of credentials.") - if self._try_needs_registration(): - self._config.add_user(credentials) - logger.info(f"New user {credentials.username} registered!") - - def _try_needs_registration(self) -> bool: - if self._is_registered(): - raise AlreadyRegisteredError( - "User has already been registered. " "Reset credentials or login." - ) - return True - - def _is_registered(self) -> bool: - return self._config and self._config.user_creds - @property def testing(self): return self._testing diff --git a/monkey/monkey_island/cc/environment/environment_config.py b/monkey/monkey_island/cc/environment/environment_config.py index 42623369e..9eba1fd6f 100644 --- a/monkey/monkey_island/cc/environment/environment_config.py +++ b/monkey/monkey_island/cc/environment/environment_config.py @@ -4,14 +4,11 @@ import json import os from typing import Dict -from monkey_island.cc.environment.user_creds import UserCreds - class EnvironmentConfig: def __init__(self, file_path): self._server_config_path = os.path.expanduser(file_path) self.server_config = None - self.user_creds = None self.aws = None self._load_from_file(self._server_config_path) @@ -24,7 +21,7 @@ class EnvironmentConfig: self._load_from_json(config_content) - def _load_from_json(self, config_json: str) -> EnvironmentConfig: + def _load_from_json(self, config_json: str): data = json.loads(config_json) self._load_from_dict(data["environment"]) @@ -32,7 +29,6 @@ class EnvironmentConfig: aws = dict_data["aws"] if "aws" in dict_data else None self.server_config = dict_data["server_config"] - self.user_creds = _get_user_credentials_from_config(dict_data) self.aws = aws def save_to_file(self): @@ -50,16 +46,4 @@ class EnvironmentConfig: } if self.aws: config_dict.update({"aws": self.aws}) - config_dict.update(self.user_creds.to_dict()) return config_dict - - def add_user(self, credentials: UserCreds): - self.user_creds = credentials - self.save_to_file() - - -def _get_user_credentials_from_config(dict_data: Dict): - username = dict_data.get("user", "") - password_hash = dict_data.get("password_hash", "") - - return UserCreds(username, password_hash)