Skip to content

Commit 7727ff1

Browse files
cakekoamssalvatore
authored andcommitted
Island: Disable default flask-security endpoints
Disables the default login, logout, and register endpoints Issue #2157 PR #3071
1 parent ee39637 commit 7727ff1

File tree

5 files changed

+24
-7
lines changed

5 files changed

+24
-7
lines changed

monkey/monkey_island/cc/app.py

+12-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,15 @@
3131
ResetAgentConfiguration,
3232
TerminateAllAgents,
3333
)
34-
from monkey_island.cc.resources.auth import Login, Logout, Register, RegistrationStatus
34+
from monkey_island.cc.resources.auth import (
35+
LOGIN_URL,
36+
LOGOUT_URL,
37+
REGISTER_URL,
38+
Login,
39+
Logout,
40+
Register,
41+
RegistrationStatus,
42+
)
3543
from monkey_island.cc.resources.exploitations.monkey_exploitation import MonkeyExploitation
3644
from monkey_island.cc.resources.island_mode import IslandMode
3745
from monkey_island.cc.resources.local_run import LocalRun
@@ -79,6 +87,9 @@ def setup_authentication(app, data_dir):
7987
# the discussion https://github.com/guardicore/monkey/pull/3006#discussion_r1116944571
8088
app.config["SECRET_KEY"] = flask_security_config["secret_key"]
8189
app.config["SECURITY_PASSWORD_SALT"] = flask_security_config["password_salt"]
90+
app.config["SECURITY_LOGIN_URL"] = LOGIN_URL
91+
app.config["SECURITY_LOGOUT_URL"] = LOGOUT_URL
92+
app.config["SECURITY_REGISTER_URL"] = REGISTER_URL
8293
app.config["SECURITY_USERNAME_ENABLE"] = True
8394
app.config["SECURITY_USERNAME_REQUIRED"] = True
8495
app.config["SECURITY_REGISTERABLE"] = True
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from .login import Login
2-
from .logout import Logout
1+
from .login import Login, LOGIN_URL
2+
from .logout import Logout, LOGOUT_URL
33
from .registration_status import RegistrationStatus
4-
from .register import Register
4+
from .register import Register, REGISTER_URL

monkey/monkey_island/cc/resources/auth/login.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,15 @@
1212

1313
logger = logging.getLogger(__name__)
1414

15+
LOGIN_URL = "/api/login"
16+
1517

1618
class Login(AbstractResource):
1719
"""
1820
A resource for user authentication
1921
"""
2022

21-
urls = ["/api/login"]
23+
urls = [LOGIN_URL]
2224

2325
def __init__(self, authentication_service: AuthenticationService):
2426
self._authentication_service = authentication_service

monkey/monkey_island/cc/resources/auth/logout.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@
1111

1212
logger = logging.getLogger(__name__)
1313

14+
LOGOUT_URL = "/api/logout"
15+
1416

1517
class Logout(AbstractResource):
1618
"""
1719
A resource logging out an authenticated user
1820
"""
1921

20-
urls = ["/api/logout"]
22+
urls = [LOGOUT_URL]
2123

2224
def __init__(self, authentication_service: AuthenticationService):
2325
self._authentication_service = authentication_service

monkey/monkey_island/cc/resources/auth/register.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,15 @@
1212

1313
logger = logging.getLogger(__name__)
1414

15+
REGISTER_URL = "/api/register"
16+
1517

1618
class Register(AbstractResource):
1719
"""
1820
A resource for user registration
1921
"""
2022

21-
urls = ["/api/register"]
23+
urls = [REGISTER_URL]
2224

2325
def __init__(self, authentication_service: AuthenticationService):
2426
self._authentication_service = authentication_service

0 commit comments

Comments
 (0)