Skip to content

Commit

Permalink
Merge pull request #58 from sgaron-msft/oauth_current_user
Browse files Browse the repository at this point in the history
Grab current_user from the authenticated session otherwise it will be wrong in oauth mode
  • Loading branch information
cccs-rs authored Dec 11, 2024
2 parents de19086 + d000426 commit 02759c3
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions assemblyline_client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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]
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 02759c3

Please sign in to comment.