@@ -55,24 +55,29 @@ def constructPrimaryIdentifier(self, data, ordered_identifier_candidates):
55
55
# name_id_format add the value for the NameID of that format if it was asserted by the IdP
56
56
# or else add the value None.
57
57
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
65
70
66
71
# Only add the NameID value asserted by the IdP if it is not already
67
72
# in the list of values. This is necessary because some non-compliant IdPs
68
73
# have been known, for example, to assert the value of eduPersonPrincipalName
69
74
# in the value for SAML2 persistent NameID as well as asserting
70
75
# 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 )
74
79
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 )
76
81
77
82
# If no value was asserted by the IdP for one of the configured list of attribute names
78
83
# for this candidate then go onto the next candidate.
0 commit comments