From a9b255e267ef08e4d41153728c97809d2fcd39a0 Mon Sep 17 00:00:00 2001 From: Sergi Delgado Segura Date: Thu, 16 Apr 2020 10:49:45 +0200 Subject: [PATCH] Removes gatekeeper from API --- teos/api.py | 9 +++------ teos/teosd.py | 2 +- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/teos/api.py b/teos/api.py index d1b31a4..e08e2e7 100644 --- a/teos/api.py +++ b/teos/api.py @@ -69,16 +69,13 @@ class API: inspector (:obj:`Inspector `): an ``Inspector`` instance to check the correctness of the received appointment data. watcher (:obj:`Watcher `): a ``Watcher`` instance to pass the requests to. - gatekeeper (:obj:`Watcher `): a `Gatekeeper` instance in charge to control the user - access. """ - def __init__(self, host, port, inspector, watcher, gatekeeper): + def __init__(self, host, port, inspector, watcher): self.host = host self.port = port self.inspector = inspector self.watcher = watcher - self.gatekeeper = gatekeeper self.app = app # Adds all the routes to the functions listed above. @@ -124,7 +121,7 @@ class API: if client_pk: try: rcode = HTTP_OK - available_slots, subscription_expiry = self.gatekeeper.add_update_user(client_pk) + available_slots, subscription_expiry = self.watcher.gatekeeper.add_update_user(client_pk) response = { "public_key": client_pk, "available_slots": available_slots, @@ -233,7 +230,7 @@ class API: message = "get appointment {}".format(locator).encode() signature = request_data.get("signature") - user_pk = self.gatekeeper.authenticate_user(message, signature) + user_pk = self.watcher.gatekeeper.authenticate_user(message, signature) triggered_appointments = self.watcher.db_manager.load_all_triggered_flags() uuid = hash_160("{}{}".format(locator, user_pk)) diff --git a/teos/teosd.py b/teos/teosd.py index 46a4fe2..2d984ce 100644 --- a/teos/teosd.py +++ b/teos/teosd.py @@ -155,7 +155,7 @@ def main(command_line_conf): # FIXME: 92-block-data-during-bootstrap-db chain_monitor.monitor_chain() inspector = Inspector(block_processor, config.get("MIN_TO_SELF_DELAY")) - API(config.get("API_BIND"), config.get("API_PORT"), inspector, watcher, gatekeeper).start() + API(config.get("API_BIND"), config.get("API_PORT"), inspector, watcher).start() except Exception as e: logger.error("An error occurred: {}. Shutting down".format(e)) exit(1)