Island: Change Environment.get_auth_expiration_time() to a constant

This commit is contained in:
Mike Salvatore 2021-11-19 08:30:22 -05:00
parent e98aa81645
commit e0fc3cec2a
2 changed files with 3 additions and 7 deletions

View File

@ -1,11 +1,11 @@
import os
import uuid
from datetime import timedelta
import flask_restful
from flask import Flask, Response, send_from_directory
from werkzeug.exceptions import NotFound
import monkey_island.cc.environment.environment_singleton as env_singleton
from common.common_consts.api_url_consts import T1216_PBA_FILE_DOWNLOAD_PATH
from monkey_island.cc.database import database, mongo
from monkey_island.cc.resources.attack.attack_config import AttackConfiguration
@ -58,6 +58,7 @@ from monkey_island.cc.services.remote_run_aws import RemoteRunAwsService
from monkey_island.cc.services.representations import output_json
HOME_FILE = "index.html"
AUTH_EXPIRATION_TIME = timedelta(minutes=30)
def serve_static_file(static_path):
@ -87,7 +88,7 @@ def init_app_config(app, mongo_url):
app.config["MONGO_URI"] = mongo_url
# See https://flask-jwt-extended.readthedocs.io/en/stable/options
app.config["JWT_ACCESS_TOKEN_EXPIRES"] = env_singleton.env.get_auth_expiration_time()
app.config["JWT_ACCESS_TOKEN_EXPIRES"] = AUTH_EXPIRATION_TIME
# Invalidate the signature of JWTs if the server process restarts. This avoids the edge case
# of getting a JWT,
# deciding to reset credentials and then still logging in with the old JWT.

View File

@ -12,8 +12,6 @@ logger = logging.getLogger(__name__)
class Environment(object, metaclass=ABCMeta):
_AUTH_EXPIRATION_TIME = timedelta(minutes=30)
_testing = False
def __init__(self, config: EnvironmentConfig):
@ -30,6 +28,3 @@ class Environment(object, metaclass=ABCMeta):
def get_config(self) -> EnvironmentConfig:
return self._config
def get_auth_expiration_time(self):
return self._AUTH_EXPIRATION_TIME