-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Shiftleader] Automatically get the list of shifters from the shift list #208
Labels
wontfix
This will not be worked on
Comments
nothingface0
changed the title
is it possible to get the list of shifters from the shift list?
[Shiftleader] Automatically get the list of shifters from the shift list
Aug 24, 2022
Code which I wrote to bypass the SAML (?) redirect and I don't want to let go to waste: from html.parser import HTMLParser
import requests
import cernrequests
class LandingPageHTMLParser(HTMLParser):
def __init__(self, *args, **kwargs):
self._found_form_url = False
self._found_saml_token = False
self.form_url = None
self.saml_token = None
super().__init__(*args, **kwargs)
def handle_starttag(self, tag, attrs):
if tag == "form":
for attr in attrs:
if attr[0] == "action":
self._found_form_url = True
self.form_url = attr[1]
elif tag == "input":
if "SAMLRequest" in [v[1] for v in attrs]:
self.saml_token = [v[1] for v in attrs if "value" in v[0]][0]
self._found_saml_token = True
# def handle_endtag(self, tag):
# pass
# def handle_data(self, data):
# print("Encountered some data :", data)
@property
def can_continue(self):
return self._found_form_url and self._found_saml_token
html_parser = LandingPageHTMLParser()
cert = cernrequests.certs.default_user_certificate_paths()
ca_bundle = cernrequests.certs.where()
response = requests.get("https://cmsonline.cern.ch/webcenter/portal/cmsonline/pages_common/shiftlist", cert=cert, verify=ca_bundle)
html_parser.feed(response.text)
if html_parser.can_continue:
print("Successfully parsed SAML page")
data = {"SAMLRequest": html_parser.saml_token}
response = requests.post(
html_parser.form_url, data=data, cert=cert, verify=ca_bundle
)
# At this point the response.url is the Auth login page This will reach the Login page, but no SSL client is allowed from this point on, meaning that the code below does not work: url = cernrequests.cookies._construct_certificate_authentication_url(
response.url
)
response = requests.get(url, cert=cert, verify=ca_bundle) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This requires some kind of access to https://cmsonline.cern.ch/webcenter/portal/cmsonline/pages_common/shiftlist
What did not work:
cernrequests
to get cookies/authenticate via SSLcern-sso
which does the sameIt either means:
Some black magic (which I don't know how you can conjure) is requiredI have queried for API availability.
Update
The text was updated successfully, but these errors were encountered: