From d000426d5dc34ef5140693a443f5508ab0887839 Mon Sep 17 00:00:00 2001 From: Steve Garon Date: Wed, 11 Dec 2024 20:31:33 +0000 Subject: [PATCH] Grab current_user from the authenticated session otherwise it will be wrong in oauth mode --- assemblyline_client/__init__.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/assemblyline_client/__init__.py b/assemblyline_client/__init__.py index c65dbf8..0ee0bf9 100644 --- a/assemblyline_client/__init__.py +++ b/assemblyline_client/__init__.py @@ -76,6 +76,7 @@ def __init__( # pylint: disable=R0913 raise ClientError("Client could not connect to the server " "due to the following SSLError: %s" % ssle, 495) + self.current_user = auth_session_detail['username'] session.timeout = auth_session_detail['session_duration'] r = self.request(self.session.get, 'api/', convert_api_output) @@ -107,19 +108,16 @@ def _authenticate(self): if self.is_v4: if self.apikey and len(self.apikey) == 2: - self.current_user = self.apikey[0] auth = { 'user': self.apikey[0], 'apikey': self.apikey[1] } elif self.auth and len(self.auth) == 2: - self.current_user = self.auth[0] auth = { 'user': self.auth[0], 'password': self.auth[1] } elif self.oauth and len(self.oauth) == 2: - self.current_user = self.oauth[0] auth = { "oauth_provider": self.oauth[0], "oauth_token": self.oauth[1] @@ -135,7 +133,6 @@ def _authenticate(self): key = key.decode("UTF-8") else: key = self.apikey[1] - self.current_user = self.apikey[0] auth = { 'user': self.apikey[0], 'apikey': key @@ -147,7 +144,6 @@ def _authenticate(self): pw = pw.decode("UTF-8") else: pw = self.auth[1] - self.current_user = self.auth[0] auth = { 'user': self.auth[0], 'password': pw