3
3
4
4
import flask_restful
5
5
from flask import Flask , Response , send_from_directory
6
- from flask_security import Security
7
6
from werkzeug .exceptions import NotFound
8
7
9
8
from common import DIContainer
10
- from monkey_island .cc .event_queue import IIslandEventQueue
11
9
from monkey_island .cc .flask_utils import FlaskDIWrapper
12
10
from monkey_island .cc .resources import (
13
11
AgentBinaries ,
36
34
from monkey_island .cc .resources .security_report import SecurityReport
37
35
from monkey_island .cc .resources .version import Version
38
36
from monkey_island .cc .server_utils .consts import MONKEY_ISLAND_ABS_PATH
39
- from monkey_island .cc .server_utils .encryption import ILockableEncryptor
40
37
from monkey_island .cc .services import register_agent_configuration_resources , setup_authentication
41
- from monkey_island .cc .services .authentication_service .authentication_facade import (
42
- AuthenticationFacade ,
43
- )
44
- from monkey_island .cc .services .authentication_service .configure_flask_security import (
45
- configure_flask_security ,
46
- )
47
- from monkey_island .cc .services .authentication_service .mongo_otp_repository import MongoOTPRepository
48
- from monkey_island .cc .services .authentication_service .token_generator import TokenGenerator
49
- from monkey_island .cc .services .authentication_service .token_parser import TokenParser
50
38
from monkey_island .cc .services .representations import output_json
51
39
52
40
HOME_FILE = "index.html"
@@ -139,7 +127,7 @@ def init_app(
139
127
data_dir : Path ,
140
128
):
141
129
"""
142
- Simple docstirng for init_app
130
+ Simple docstring for init_app
143
131
144
132
:param mongo_url: A url
145
133
:param container: Dependency injection container
@@ -152,31 +140,8 @@ def init_app(
152
140
init_app_config (app )
153
141
init_app_url_rules (app )
154
142
143
+ setup_authentication (api , app , container , data_dir )
155
144
flask_resource_manager = FlaskDIWrapper (api , container )
156
- datastore = configure_flask_security (app , data_dir )
157
- authentication_facade = _build_authentication_facade (container , datastore )
158
- setup_authentication (api , authentication_facade )
159
145
init_api_resources (flask_resource_manager )
160
146
161
147
return app
162
-
163
-
164
- def _build_authentication_facade (container : DIContainer , security : Security ):
165
- repository_encryptor = container .resolve (ILockableEncryptor )
166
- island_event_queue = container .resolve (IIslandEventQueue )
167
-
168
- token_generator = TokenGenerator (security )
169
- refresh_token_expiration = (
170
- security .app .config ["SECURITY_TOKEN_MAX_AGE" ]
171
- + security .app .config ["SECURITY_REFRESH_TOKEN_TIMEDELTA" ]
172
- )
173
- token_parser = TokenParser (security , refresh_token_expiration )
174
-
175
- return AuthenticationFacade (
176
- repository_encryptor ,
177
- island_event_queue ,
178
- security .datastore ,
179
- token_generator ,
180
- token_parser ,
181
- container .resolve (MongoOTPRepository ),
182
- )
0 commit comments