Skip to content

Commit

Permalink
Merge pull request #93 from AikidoSec/AIK-3348
Browse files Browse the repository at this point in the history
Don't start heartbeat and realtime polling if token invalid
  • Loading branch information
willem-delbare authored Aug 21, 2024
2 parents ab21db9 + e54d1f8 commit 95b3d93
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
8 changes: 7 additions & 1 deletion aikido_firewall/background_process/reporter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from aikido_firewall.background_process.heartbeats import send_heartbeats_every_x_secs
from aikido_firewall.background_process.routes import Routes
from aikido_firewall.ratelimiting.rate_limiter import RateLimiter
from aikido_firewall.helpers.logging import logger
from ..service_config import ServiceConfig
from ..users import Users
from ..hostnames import Hostnames
Expand Down Expand Up @@ -48,7 +49,12 @@ def __init__(self, block, api, token, serverless):

def start(self, event_scheduler):
"""Send out start event and add heartbeats"""
self.on_start()
res = self.on_start()
if res.get("error", None) == "invalid_token":
logger.info(
"Token was invalid, not starting heartbeats and realtime polling."
)
return
send_heartbeats_every_x_secs(self, self.heartbeat_secs, event_scheduler)
start_polling_for_changes(
self.update_service_config, self.serverless, self.token, event_scheduler
Expand Down
1 change: 1 addition & 0 deletions aikido_firewall/background_process/reporter/on_start.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ def on_start(reporter):
else:
reporter.update_service_config(res)
logger.info("Established connection with Aikido Server")
return res

0 comments on commit 95b3d93

Please sign in to comment.