Skip to content

Commit 737f274

Browse files
author
Michael Erickson
committed
Fixes to Sessions created via swat.CAS object
1 parent 4b57149 commit 737f274

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

src/sasctl/core.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -351,17 +351,19 @@ def is_ipaddress(hst):
351351
# REST endpoints
352352
httpAddress = hostname.get_action("builtins.httpAddress")
353353
address = httpAddress()
354-
domain = address.virtualHost
355-
# httpAddress action may return virtualHost = ''
356-
# if this happens, try the CAS host
357-
if not domain:
358-
domain = hostname._sw_connection._current_hostname
354+
# Retrieve domain via swat connection object instead of httpAddress
355+
domain = hostname._sw_connection._current_hostname
359356
protocol = address.protocol
360357
port = address.port
361-
auth = hostname._sw_connection._auth.decode("utf-8").replace(
362-
"Basic ", ""
363-
)
364-
username, password = base64.b64decode(auth).decode("utf-8").split(":")
358+
auth = hostname._sw_connection._auth.decode("utf-8")
359+
# Checks to see if authentication was made via user/pass or auth token
360+
if(auth.startswith("Basic")):
361+
# User/pass
362+
auth = auth.replace("Basic ", "")
363+
username, password = base64.b64decode(auth).decode("utf-8").split(":")
364+
elif(auth.startswith("Bearer")):
365+
# Auth token
366+
token = auth.replace("Bearer ", "")
365367
else:
366368
raise ValueError(
367369
"A 'swat.CAS' session can only be reused "

0 commit comments

Comments
 (0)