Island: Add new RegistrationStatus resource

This commit is contained in:
Shreya Malviya 2022-08-02 14:11:03 +05:30
parent 9442b66912
commit 420839d0bc
2 changed files with 15 additions and 0 deletions

View File

@ -23,6 +23,7 @@ from monkey_island.cc.resources.agent_controls import StopAgentCheck, StopAllAge
from monkey_island.cc.resources.attack.attack_report import AttackReport from monkey_island.cc.resources.attack.attack_report import AttackReport
from monkey_island.cc.resources.auth.authenticate import Authenticate, init_jwt from monkey_island.cc.resources.auth.authenticate import Authenticate, init_jwt
from monkey_island.cc.resources.auth.register import Registration from monkey_island.cc.resources.auth.register import Registration
from monkey_island.cc.resources.auth.registration_status import RegistrationStatus
from monkey_island.cc.resources.blackbox.log_blackbox_endpoint import LogBlackboxEndpoint from monkey_island.cc.resources.blackbox.log_blackbox_endpoint import LogBlackboxEndpoint
from monkey_island.cc.resources.blackbox.monkey_blackbox_endpoint import MonkeyBlackboxEndpoint from monkey_island.cc.resources.blackbox.monkey_blackbox_endpoint import MonkeyBlackboxEndpoint
from monkey_island.cc.resources.blackbox.telemetry_blackbox_endpoint import ( from monkey_island.cc.resources.blackbox.telemetry_blackbox_endpoint import (
@ -153,6 +154,7 @@ def init_api_resources(api: FlaskDIWrapper):
def init_restful_endpoints(api: FlaskDIWrapper): def init_restful_endpoints(api: FlaskDIWrapper):
api.add_resource(Root) api.add_resource(Root)
api.add_resource(Registration) api.add_resource(Registration)
api.add_resource(RegistrationStatus)
api.add_resource(Authenticate) api.add_resource(Authenticate)
api.add_resource(Monkey) api.add_resource(Monkey)
api.add_resource(LocalRun) api.add_resource(LocalRun)

View File

@ -0,0 +1,13 @@
from monkey_island.cc.resources.AbstractResource import AbstractResource
from monkey_island.cc.services import AuthenticationService
class RegistrationStatus(AbstractResource):
urls = ["/api/registration-status"]
def __init__(self, authentication_service: AuthenticationService):
self._authentication_service = authentication_service
def get(self):
return {"needs_registration": self._authentication_service.needs_registration()}