Skip to content

Commit

Permalink
use variable instead of string for endpoint url
Browse files Browse the repository at this point in the history
  • Loading branch information
Kleinrotti committed Jun 13, 2022
1 parent b444b20 commit ea2a422
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/senertec/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ def __init__(self, dataNames=None, email: str = None, password: str = None, lang
datefmt='%Y-%m-%d %H:%M:%S'
)
self.AUTHENTICATION_HOST = "https://dachsconnect.senertec.com"
self.SSO_HOST = "https://sso-portal.senertec.com"
self.email = email
self.__session__ = None
self.language = language
Expand Down Expand Up @@ -216,13 +217,13 @@ def login(self):
self.logger.info("Logging in..")
self.__session__ = requests.Session()
loginSSOResponse = self.__session__.get(
"https://dachsconnect.senertec.com/rest/saml2/login")
self.AUTHENTICATION_HOST + "/rest/saml2/login")

authState = loginSSOResponse.url.split("loginuserpass.php?")[1]
head = {"Content-Type": "application/x-www-form-urlencoded"}
userData = f"username={self.email}&password={self.password}&{authState}"
# submit credentials
loginResponse = self.__session__.post("https://sso-portal.senertec.com/simplesaml/module.php/core/loginuserpass.php?",
loginResponse = self.__session__.post(self.SSO_HOST + "/simplesaml/module.php/core/loginuserpass.php?",
data=userData, headers=head)

# filter out samlresponse and relaystate for ACS request
Expand All @@ -239,7 +240,7 @@ def login(self):

# do assertion consumer service request with received saml response
acs = self.__session__.post(
"https://dachsconnect.senertec.com/rest/saml2/acs", data=acsData, headers=head)
self.AUTHENTICATION_HOST + "/rest/saml2/acs", data=acsData, headers=head)

if acs.history[0].status_code != 302:
self.logger.error("Login failed at ACS request, got no redirect.")
Expand Down

0 comments on commit ea2a422

Please sign in to comment.