Skip to content

Commit ee8c8f1

Browse files
committed
Make use of InternalData properties
Signed-off-by: Ivan Kanakarakis <[email protected]>
1 parent 6480bd2 commit ee8c8f1

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

src/satosa/micro_services/primary_identifier.py

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,24 +55,29 @@ def constructPrimaryIdentifier(self, data, ordered_identifier_candidates):
5555
# name_id_format add the value for the NameID of that format if it was asserted by the IdP
5656
# or else add the value None.
5757
if 'name_id' in candidate['attribute_names']:
58-
nameid_value = None
59-
if 'name_id' in data.to_dict():
60-
name_id = data.to_dict()['name_id']
61-
satosa_logging(logger, logging.DEBUG, "{} IdP asserted NameID {}".format(logprefix, name_id), context.state)
62-
if 'name_id_format' in candidate:
63-
if candidate['name_id_format'] in name_id:
64-
nameid_value = name_id[candidate['name_id_format']]
58+
candidate_nameid_value = None
59+
candidate_nameid_value = None
60+
candidate_name_id_format = candidate.get('name_id_format')
61+
name_id_value = data.subject_id
62+
name_id_format = data.subject_type
63+
if (
64+
name_id_value
65+
and candidate_name_id_format
66+
and candidate_name_id_format == name_id_format
67+
):
68+
satosa_logging(logger, logging.DEBUG, "{} IdP asserted NameID {}".format(logprefix, name_id_value), context.state)
69+
candidate_nameid_value = name_id_value
6570

6671
# Only add the NameID value asserted by the IdP if it is not already
6772
# in the list of values. This is necessary because some non-compliant IdPs
6873
# have been known, for example, to assert the value of eduPersonPrincipalName
6974
# in the value for SAML2 persistent NameID as well as asserting
7075
# eduPersonPrincipalName.
71-
if nameid_value not in values:
72-
satosa_logging(logger, logging.DEBUG, "{} Added NameID {} to candidate values".format(logprefix, nameid_value), context.state)
73-
values.append(nameid_value)
76+
if candidate_nameid_value not in values:
77+
satosa_logging(logger, logging.DEBUG, "{} Added NameID {} to candidate values".format(logprefix, candidate_nameid_value), context.state)
78+
values.append(candidate_nameid_value)
7479
else:
75-
satosa_logging(logger, logging.WARN, "{} NameID {} value also asserted as attribute value".format(logprefix, nameid_value), context.state)
80+
satosa_logging(logger, logging.WARN, "{} NameID {} value also asserted as attribute value".format(logprefix, candidate_nameid_value), context.state)
7681

7782
# If no value was asserted by the IdP for one of the configured list of attribute names
7883
# for this candidate then go onto the next candidate.

0 commit comments

Comments
 (0)