Skip to content

Docstrings improvements for NameID and argtree.add_path #538

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions src/saml2/argtree.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]:
Expand Down
11 changes: 10 additions & 1 deletion src/saml2/saml.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down