Created
April 26, 2021 15:07
-
-
Save daserzw/f05d6f37d5246ee31cbf90c857458c0e to your computer and use it in GitHub Desktop.
eduGAIN scope and orgname
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import requests | |
from xml.etree import ElementTree as ET | |
def strip_start(s, start): | |
if s.startswith(start): | |
return s[len(start):] | |
return s | |
xml_req = requests.get('https://md.idem.garr.it/metadata/edugain2idem-metadata-sha256.xml') | |
root = ET.fromstring(xml_req.content) | |
orgs = set() | |
ns = { | |
'md': 'urn:oasis:names:tc:SAML:2.0:metadata', | |
'mdui': 'urn:oasis:names:tc:SAML:metadata:ui', | |
'shibmd': 'urn:mace:shibboleth:metadata:1.0', | |
'remd': 'http://refeds.org/metadata', | |
'icmd': 'http://id.incommon.org/metadata', | |
'mdrpi': 'urn:oasis:names:tc:SAML:metadata:rpi', | |
} | |
entities = root.findall('./md:EntityDescriptor', ns) | |
for entity in entities: | |
sec_mails = set() | |
orgname = entity.find('./md:Organization/md:OrganizationDisplayName', ns).text.strip() | |
if not orgname: | |
continue | |
doms = entity.findall('./md:IDPSSODescriptor/md:Extensions/shibmd:Scope[@regexp="false"]', ns) | |
doms_set = set() | |
for dom in doms: | |
doms_set.add(dom.text) | |
for domain in doms_set: | |
orgs.add('"{}","{}"'.format(domain, orgname)) | |
for org in sorted(orgs): | |
print(org) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment