Skip to content

Commit

Permalink
Fixed login issue
Browse files Browse the repository at this point in the history
  • Loading branch information
DaanVervacke committed Dec 7, 2021
1 parent 2f3a9ca commit 54bbbc1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
9 changes: 7 additions & 2 deletions toledo/portal.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import yaml

from toledo.utils import set_user_agent
from toledo.utils import clear_session

from toledo.utils import get_start_html
from toledo.utils import get_saml2_relay_and_request
Expand Down Expand Up @@ -47,17 +48,21 @@ def __call__(self) -> requests.Session:

try:


if '' in (self._USER, self._PASSWORD):

raise Exception('Please check your credentials!')

# 1. Toledo Portal

# Clear session
clear_session()

# Set User-Agent
set_user_agent(
user_agent=self._USER_AGENT
)

# Load Toledo Portal
portal_html = get_start_html(
url=self._PORTALURL
Expand All @@ -67,7 +72,7 @@ def __call__(self) -> requests.Session:
relaystate_samlrequest = get_saml2_relay_and_request(
html=portal_html
)

# Post RelayState & SAMLRequest
first_csrf_html = post_saml2_relay_and_request(
post_info=relaystate_samlrequest
Expand Down
8 changes: 6 additions & 2 deletions toledo/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,17 @@

SESSION = requests.Session()


def set_user_agent(user_agent: str):
def set_user_agent(user_agent: str) -> None:

SESSION.headers.update({
'User-Agent': user_agent
})

def clear_session() -> None:

SESSION.headers.clear()
SESSION.cookies.clear()


''' SAML2 GET METHODS '''

Expand Down

0 comments on commit 54bbbc1

Please sign in to comment.