Removes gatekeeper from API

This commit is contained in:
Sergi Delgado Segura
2020-04-16 10:49:45 +02:00
parent 8e3caadc5c
commit a9b255e267
2 changed files with 4 additions and 7 deletions

View File

@@ -69,16 +69,13 @@ class API:
inspector (:obj:`Inspector <teos.inspector.Inspector>`): an ``Inspector`` instance to check the correctness of
the received appointment data.
watcher (:obj:`Watcher <teos.watcher.Watcher>`): a ``Watcher`` instance to pass the requests to.
gatekeeper (:obj:`Watcher <teos.gatekeeper.Gatekeeper>`): 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))

View File

@@ -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)