diff options
author | Ivan Kanakarakis <ivan.kanak@gmail.com> | 2018-08-24 10:15:47 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-24 10:15:47 +0300 |
commit | 9eb34a9b048b5897d41db730ab3d9ab777465554 (patch) | |
tree | 4d5aa77750e6f3343d7575db2f8d8587ac97ed1b | |
parent | 7135d985aa49d17b0bcc4a433a363da945e3b0ab (diff) | |
parent | 40c5452dcd38ba20d6a8cefb56ba2a8e146921ad (diff) | |
download | pysaml2-9eb34a9b048b5897d41db730ab3d9ab777465554.tar.gz |
Merge pull request #538 from sheilatron/Docstrings4Learning
Improve docstring for NameID and argtree.add_path
-rw-r--r-- | src/saml2/argtree.py | 24 | ||||
-rw-r--r-- | src/saml2/saml.py | 11 |
2 files changed, 34 insertions, 1 deletions
diff --git a/src/saml2/argtree.py b/src/saml2/argtree.py index cda8ab42..468b7f07 100644 --- a/src/saml2/argtree.py +++ b/src/saml2/argtree.py @@ -53,10 +53,34 @@ def set_arg(cls, arg, value): def add_path(tdict, path): """ + Create or extend an argument tree `tdict` from `path`. :param tdict: a dictionary representing a argument tree :param path: a path list :return: a dictionary + + Convert a list of items in a 'path' into a nested dict, where the + second to last item becomes the key for the final item. The remaining + items in the path become keys in the nested dict around that final pair + of items. + + For example, for input values of: + tdict={} + path = ['assertion', 'subject', 'subject_confirmation', + 'method', 'urn:oasis:names:tc:SAML:2.0:cm:bearer'] + + Returns an output value of: + {'assertion': {'subject': {'subject_confirmation': + {'method': 'urn:oasis:names:tc:SAML:2.0:cm:bearer'}}}} + + Another example, this time with a non-empty tdict input: + + tdict={'method': 'urn:oasis:names:tc:SAML:2.0:cm:bearer'}, + path=['subject_confirmation_data', 'in_response_to', '_012345'] + + Returns an output value of: + {'subject_confirmation_data': {'in_response_to': '_012345'}, + 'method': 'urn:oasis:names:tc:SAML:2.0:cm:bearer'} """ t = tdict for step in path[:-2]: diff --git a/src/saml2/saml.py b/src/saml2/saml.py index 8807966c..023f352f 100644 --- a/src/saml2/saml.py +++ b/src/saml2/saml.py @@ -811,7 +811,16 @@ def base_id_from_string(xml_string): class NameID(NameIDType_): - """The urn:oasis:names:tc:SAML:2.0:assertion:NameID element """ + """The urn:oasis:names:tc:SAML:2.0:assertion:NameID element + + From the Oasis SAML2 Technical Overview: + + "The <NameID> element within a <Subject> offers the ability to provide name + identifiers in a number of different formats. SAML's predefined formats + include: Email address, X.509 subject name, Windows domain qualified name, + Kerberos principal name, Entity identifier, Persistent identifier, + Transient identifier." + """ c_tag = 'NameID' c_namespace = NAMESPACE |