From 153d8790022e861121ad464e210b4c0132e17e30 Mon Sep 17 00:00:00 2001 From: enriquepablo Date: Fri, 22 Mar 2024 16:30:29 +0100 Subject: [PATCH] add DiscoveryResponse info to SPs in discojson --- NEWS.txt | 3 +++ src/pyff/constants.py | 1 + src/pyff/samlmd.py | 12 ++++++++++++ 3 files changed, 16 insertions(+) diff --git a/NEWS.txt b/NEWS.txt index 366a405f..0b2f56f6 100644 --- a/NEWS.txt +++ b/NEWS.txt @@ -171,3 +171,6 @@ to sign using HSMs. The only mandatory non-python dependency now is lxml. * Fix random seeding * Fix for data handling related to non-Z timezones in metadata +2.1.3 +----- +* Add DiscoveryResponse info to SPs in discojson diff --git a/src/pyff/constants.py b/src/pyff/constants.py index 7bc8f5c9..469782ce 100644 --- a/src/pyff/constants.py +++ b/src/pyff/constants.py @@ -37,6 +37,7 @@ ser="http://eidas.europa.eu/metadata/servicelist", eidas="http://eidas.europa.eu/saml-extensions", ti="https://seamlessaccess.org/NS/trustinfo", + idpdisc="urn:oasis:names:tc:SAML:profiles:SSO:idp-discovery-protocol", ) #: These are the attribute aliases pyFF knows about. These are used to build URI paths, populate the index diff --git a/src/pyff/samlmd.py b/src/pyff/samlmd.py index 1c86f957..8f1f383d 100644 --- a/src/pyff/samlmd.py +++ b/src/pyff/samlmd.py @@ -783,6 +783,14 @@ def registration_authority(entity): return regauth_el.attrib.get('registrationAuthority') +def discovery_responses(entity): + responses = None + responses_els = entity.findall(".//{%s}DiscoveryResponse" % NS['idpdisc']) + if len(responses_els) > 0: + responses = [el.attrib.get('Location') for el in responses_els] + return responses + + def entity_extended_display(entity, langs=None): """Utility-method for computing a displayable string for a given entity. @@ -875,6 +883,7 @@ def discojson(e, sources=None, langs=None, fallback_to_favicon=False, icon_store categories = entity_attribute(e, "http://macedir.org/entity-category") certifications = entity_attribute(e, "urn:oasis:names:tc:SAML:attribute:assurance-certification") cat_support = entity_attribute(e, "http://macedir.org/entity-category-support") + disc_responses = discovery_responses(e) d = dict( title=title, @@ -900,6 +909,9 @@ def discojson(e, sources=None, langs=None, fallback_to_favicon=False, icon_store if sources is not None: d['md_source'] = sources + if disc_responses is not None: + d["discovery_responses"] = disc_responses + eattr = entity_attribute_dict(e) if 'idp' in eattr[ATTRS['role']]: d['type'] = 'idp'