Skip to content

Commit 02842c6

Browse files
authored
Refresh token when connectin to saas (#1848)
1 parent 89b9880 commit 02842c6

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

src/robusta/integrations/receiver.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,14 @@ class SlackActionsMessage(BaseModel):
7676

7777

7878
class ActionRequestReceiver:
79-
def __init__(self, event_handler: PlaybooksEventHandler, auth_token: str):
79+
def __init__(self, event_handler: PlaybooksEventHandler, robusta_sink: "RobustaSink"):
8080
self.event_handler = event_handler
8181
self.active = True
8282
self.account_id = self.event_handler.get_global_config().get("account_id")
8383
self.cluster_name = self.event_handler.get_global_config().get("cluster_name")
8484
self.auth_provider = AuthProvider()
8585
self.healthy = False
86-
self.auth_token = auth_token
86+
self.robusta_sink = robusta_sink
8787

8888
self.ws = websocket.WebSocketApp(
8989
WEBSOCKET_RELAY_ADDRESS,
@@ -287,12 +287,13 @@ def on_error(self, ws, error):
287287
def on_open(self, ws):
288288
account_id = self.event_handler.get_global_config().get("account_id")
289289
cluster_name = self.event_handler.get_global_config().get("cluster_name")
290+
token = self.robusta_sink.dal.get_session_token()
290291
open_payload = {
291292
"action": "auth",
292293
"account_id": account_id,
293294
"cluster_name": cluster_name,
294295
"version": RUNNER_VERSION,
295-
"token": self.auth_token,
296+
"token": token,
296297
}
297298
logging.info(f"connecting to server as account_id={account_id}; cluster_name={cluster_name}")
298299
ws.send(json.dumps(open_payload))

src/robusta/runner/config_loader.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,8 @@ def __create_receiver(self):
105105
return
106106

107107
robusta_sink = robusta_sinks[0]
108-
token = robusta_sink.dal.get_session_token()
109108

110-
receiver = ActionRequestReceiver(self.event_handler, token)
109+
receiver = ActionRequestReceiver(self.event_handler, robusta_sink)
111110
self.registry.set_receiver(receiver)
112111
return receiver
113112

0 commit comments

Comments
 (0)