summaryrefslogtreecommitdiff
path: root/src/saml2/metadata.py
diff options
context:
space:
mode:
authorIvan Kanakarakis <ivan.kanak@gmail.com>2020-07-11 18:26:38 +0300
committerIvan Kanakarakis <ivan.kanak@gmail.com>2020-07-11 19:11:19 +0300
commite5d0b4f0760144430d885165d41d777b59ef5d6a (patch)
treeb86960a5b7e3b871d96d7cbc448e302e964a5a90 /src/saml2/metadata.py
parent21eb11fa2333b85309257a7627b794242ebe6b8d (diff)
downloadpysaml2-e5d0b4f0760144430d885165d41d777b59ef5d6a.tar.gz
Support arbitrary entity attributes
Introduce new configuration option `entity_attributes` that defines a list of dictionaries each of which represents an <Attribute> element. Each dicrionary has fields for the NameFormat, the Name, the FriendName and a list of strings that are used to create <AttributeValue> elements, each with the string as the text node. "entity_attributes": [ { "name_format": "urn:oasis:names:tc:SAML:2.0:attrname-format:uri", "name": "urn:oasis:names:tc:SAML:profiles:subject-id:req", # "friendly_name" is not set "values": ["any"], }, ] Signed-off-by: Ivan Kanakarakis <ivan.kanak@gmail.com>
Diffstat (limited to 'src/saml2/metadata.py')
-rw-r--r--src/saml2/metadata.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/saml2/metadata.py b/src/saml2/metadata.py
index d80b41ac..50b4ff71 100644
--- a/src/saml2/metadata.py
+++ b/src/saml2/metadata.py
@@ -708,6 +708,24 @@ def entity_descriptor(confd):
if confd.contact_person is not None:
entd.contact_person = do_contact_persons_info(confd.contact_person)
+ if confd.entity_attributes:
+ if not entd.extensions:
+ entd.extensions = md.Extensions()
+ attributes = [
+ Attribute(
+ name_format=attr.get("format"),
+ name=attr.get("name"),
+ friendly_name=attr.get("friendly_name"),
+ attribute_value=[
+ AttributeValue(text=value)
+ for value in attr.get("values", [])
+ ],
+ )
+ for attr in confd.entity_attributes
+ ]
+ for attribute in attributes:
+ _add_attr_to_entity_attributes(entd.extensions, attribute)
+
if confd.assurance_certification:
if not entd.extensions:
entd.extensions = md.Extensions()