Skip to content

Commit

Permalink
Smud login fix (#107)
Browse files Browse the repository at this point in the history
* update log message

* Commented-out code related to Okta SAML login process

* Refactor comment formatting for network inspector logging instructions

* remove comments and cleanup line lengths
  • Loading branch information
andylittle authored Dec 29, 2024
1 parent 05ae986 commit 68be604
Showing 1 changed file with 2 additions and 40 deletions.
42 changes: 2 additions & 40 deletions src/opower/utilities/smud.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#
# To filter FireFox network inspector when logging in:
# `-regexp:woff|beacon|appdynamics|fonts|css|hotjar|usabilla|chat|ico|analytics|promo|nextprofilequestion|trackEvent
# -mime-type:image`
# -mime-type:image`
#
# Test with:
# `python src/demo.py --utility smud --username [email protected] --password "mypassword" -v`
Expand Down Expand Up @@ -275,49 +275,11 @@ async def async_login(
await SMUD.log_response(identity_oraclecloud_login_response, session)

okta_saml_request_url = identity_oraclecloud_login_response.real_url

_LOGGER.debug(
"Fetching okta saml page with SAMLRequest, RelayState: %s",
okta_saml_request_url,
)

okta_saml_request_response = await session.get(
"RESPONSE from opower sso login page with OCIS_REQ_SP, RelayState: %s",
okta_saml_request_url,
headers={"User-Agent": USER_AGENT},
raise_for_status=True,
)

await SMUD.log_response(okta_saml_request_response, session)

parser2 = SMUDOktaResponseSamlResponseValueParser()
parser2.feed(await okta_saml_request_response.text())
saml_response = parser2.saml_response
assert saml_response

login_parser.feed(await okta_saml_request_response.text())
relay_state = login_parser.relay_state

opower_sso_acs_url = "https://sso.opower.com/sp/ACS.saml2"

_LOGGER.debug(
"POSTing opower ACS sso page with SAMLResponse: %s", opower_sso_acs_url
)

opower_sso_acs_response = await session.post(
opower_sso_acs_url,
data={
"SAMLResponse": saml_response,
"RelayState": relay_state,
},
headers={"User-Agent": USER_AGENT},
raise_for_status=True,
allow_redirects=True,
)

await SMUD.log_response(opower_sso_acs_response, session)

_LOGGER.debug("End of SMUD login process")

return

@classmethod
Expand Down

0 comments on commit 68be604

Please sign in to comment.