forked from p34709852/monkey
Merge remote-tracking branch 'upstream/password_setup' into password_setup
This commit is contained in:
commit
938a5e225c
|
@ -3,6 +3,7 @@ import logging
|
|||
import os
|
||||
from abc import ABCMeta, abstractmethod
|
||||
from datetime import timedelta
|
||||
import json
|
||||
|
||||
__author__ = 'itay.mizeretz'
|
||||
|
||||
|
@ -52,6 +53,7 @@ class Environment(object, metaclass=ABCMeta):
|
|||
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 not self._credentials_required:
|
||||
|
|
|
@ -1,16 +1,19 @@
|
|||
import json
|
||||
import logging
|
||||
|
||||
from flask import request
|
||||
import flask_restful
|
||||
|
||||
import monkey_island.cc.environment.environment_singleton as env_singleton
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class Environment(flask_restful.Resource):
|
||||
|
||||
def patch(self):
|
||||
env_data = json.loads(request.data)
|
||||
if env_data['server_config'] == "standard":
|
||||
if env_singleton.env.needs_registration():
|
||||
env_singleton.set_to_standard()
|
||||
logger.warning("No user registered, Island on standard mode - no credentials required to access.")
|
||||
return {}
|
||||
|
|
Loading…
Reference in New Issue