Skip to content

Commit b1e8b65

Browse files
committed
Add eIDAS NodeCountry and NodeCountryType basic support
- Adds schemas and auto-generated .py files for eIDAS NodeCountry and NodeCountryType support - Adds node_country as a recognized attribute in the configuration of an SP/IdP - Adds node_country parsing for the construction of the entity descriptor as an extension element
1 parent 324656e commit b1e8b65

File tree

4 files changed

+75
-0
lines changed

4 files changed

+75
-0
lines changed

src/saml2/config.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@
9797
"sp_type",
9898
"sp_type_in_metadata",
9999
"requested_attributes",
100+
"node_country",
100101
]
101102

102103
AA_IDP_ARGS = [
@@ -118,6 +119,7 @@
118119
"domain",
119120
"name_qualifier",
120121
"edu_person_targeted_id",
122+
"node_country",
121123
]
122124

123125
PDP_ARGS = ["endpoints", "name_form", "name_id_format"]

src/saml2/extension/node_country.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/usr/bin/env python
2+
3+
#
4+
# Generated Thu Dec 12 18:16:51 2019 by parse_xsd.py version 0.5.
5+
#
6+
7+
import saml2
8+
from saml2 import SamlBase
9+
10+
11+
NAMESPACE = 'http://eidas.europa.eu/saml-extensions'
12+
class NodeCountryType_(SamlBase):
13+
"""The http://eidas.europa.eu/saml-extensions:NodeCountryType element """
14+
15+
c_tag = 'NodeCountryType'
16+
c_namespace = NAMESPACE
17+
c_children = SamlBase.c_children.copy()
18+
c_attributes = SamlBase.c_attributes.copy()
19+
c_child_order = SamlBase.c_child_order[:]
20+
c_cardinality = SamlBase.c_cardinality.copy()
21+
22+
def node_country_type__from_string(xml_string):
23+
return saml2.create_class_from_xml_string(NodeCountryType_, xml_string)
24+
25+
26+
class NodeCountry(NodeCountryType_):
27+
"""The http://eidas.europa.eu/saml-extensions:NodeCountry element """
28+
29+
c_tag = 'NodeCountry'
30+
c_namespace = NAMESPACE
31+
c_children = NodeCountryType_.c_children.copy()
32+
c_attributes = NodeCountryType_.c_attributes.copy()
33+
c_child_order = NodeCountryType_.c_child_order[:]
34+
c_cardinality = NodeCountryType_.c_cardinality.copy()
35+
36+
def node_country_from_string(xml_string):
37+
return saml2.create_class_from_xml_string(NodeCountry, xml_string)
38+
39+
40+
ELEMENT_FROM_STRING = {
41+
NodeCountry.c_tag: node_country_from_string,
42+
NodeCountryType_.c_tag: node_country_type__from_string,
43+
}
44+
45+
ELEMENT_BY_TAG = {
46+
'NodeCountry': NodeCountry,
47+
'NodeCountryType': NodeCountryType_,
48+
}
49+
def factory(tag, **kwargs):
50+
return ELEMENT_BY_TAG[tag](**kwargs)

src/saml2/metadata.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from saml2.extension import shibmd
1111
from saml2.extension import mdattr
1212
from saml2.extension import sp_type
13+
from saml2.extension import node_country
1314
from saml2.saml import NAME_FORMAT_URI
1415
from saml2.saml import AttributeValue
1516
from saml2.saml import Attribute
@@ -770,6 +771,13 @@ def entity_descriptor(confd):
770771
entd.authn_authority_descriptor = do_aq_descriptor(confd, mycert,
771772
enc_cert)
772773

774+
conf_node_country = confd.getattr('node_country', confd.context)
775+
if conf_node_country:
776+
if not entd.extensions:
777+
entd.extensions = md.Extensions()
778+
item = node_country.NodeCountry(text=conf_node_country)
779+
entd.extensions.add_extension_element(item)
780+
773781
return entd
774782

775783

tools/data/node_country.xsd

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<xsd:schema
3+
xmlns="http://eidas.europa.eu/saml-extensions"
4+
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
5+
targetNamespace="http://eidas.europa.eu/saml-extensions"
6+
elementFormDefault="qualified"
7+
attributeFormDefault="unqualified"
8+
version="1">
9+
<xsd:element name="NodeCountry" type="NodeCountryType"/>
10+
<xsd:simpleType name="NodeCountryType">
11+
<xsd:restriction base="xsd:string">
12+
<xsd:pattern value="[A-Z][A-Z]"/>
13+
</xsd:restriction>
14+
</xsd:simpleType>
15+
</xsd:schema>

0 commit comments

Comments
 (0)