forked from p15670423/monkey
Adding some server logs re: registration
Will possibly help debug client issues with registration in future.
This commit is contained in:
parent
e58cdee246
commit
da58ea7250
|
@ -3,6 +3,7 @@ import logging
|
||||||
import os
|
import os
|
||||||
from abc import ABCMeta, abstractmethod
|
from abc import ABCMeta, abstractmethod
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
import json
|
||||||
|
|
||||||
__author__ = 'itay.mizeretz'
|
__author__ = 'itay.mizeretz'
|
||||||
|
|
||||||
|
@ -52,6 +53,7 @@ class Environment(object, metaclass=ABCMeta):
|
||||||
raise InvalidRegistrationCredentialsError("Missing part of credentials.")
|
raise InvalidRegistrationCredentialsError("Missing part of credentials.")
|
||||||
if self._try_needs_registration():
|
if self._try_needs_registration():
|
||||||
self._config.add_user(credentials)
|
self._config.add_user(credentials)
|
||||||
|
logger.info(f"New user {credentials.username} registered!")
|
||||||
|
|
||||||
def _try_needs_registration(self) -> bool:
|
def _try_needs_registration(self) -> bool:
|
||||||
if not self._credentials_required:
|
if not self._credentials_required:
|
||||||
|
|
|
@ -1,16 +1,19 @@
|
||||||
import json
|
import json
|
||||||
|
import logging
|
||||||
|
|
||||||
from flask import request
|
from flask import request
|
||||||
import flask_restful
|
import flask_restful
|
||||||
|
|
||||||
import monkey_island.cc.environment.environment_singleton as env_singleton
|
import monkey_island.cc.environment.environment_singleton as env_singleton
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class Environment(flask_restful.Resource):
|
class Environment(flask_restful.Resource):
|
||||||
|
|
||||||
def patch(self):
|
def patch(self):
|
||||||
env_data = json.loads(request.data)
|
env_data = json.loads(request.data)
|
||||||
if env_data['server_config'] == "standard":
|
if env_data['server_config'] == "standard":
|
||||||
if env_singleton.env.needs_registration():
|
if env_singleton.env.needs_registration():
|
||||||
env_singleton.set_to_standard()
|
env_singleton.set_to_standard()
|
||||||
|
logger.warning("No user registered, Island on standard mode - no credentials required to access.")
|
||||||
return {}
|
return {}
|
||||||
|
|
Loading…
Reference in New Issue