@@ -166,24 +166,28 @@ def _construct_filter_value(self, candidate, data):
166
166
# name_id_format add the value for the NameID of that format if it was asserted by the IdP
167
167
# or else add the value None.
168
168
if 'name_id' in candidate ['attribute_names' ]:
169
- nameid_value = None
170
- if 'name_id' in data .to_dict ():
171
- name_id = data .to_dict ()['name_id' ]
172
- satosa_logging (logger , logging .DEBUG , "IdP asserted NameID {}" .format (name_id ), context .state )
173
- if 'name_id_format' in candidate :
174
- if candidate ['name_id_format' ] in name_id :
175
- nameid_value = name_id [candidate ['name_id_format' ]]
169
+ candidate_nameid_value = None
170
+ candidate_name_id_format = candidate .get ('name_id_format' )
171
+ name_id_value = data .subject_id
172
+ name_id_format = data .subject_type
173
+ if (
174
+ name_id_value
175
+ and candidate_name_id_format
176
+ and candidate_name_id_format == name_id_format
177
+ ):
178
+ satosa_logging (logger , logging .DEBUG , "IdP asserted NameID {}" .format (name_id_value ), context .state )
179
+ candidate_nameid_value = name_id_value
176
180
177
181
# Only add the NameID value asserted by the IdP if it is not already
178
182
# in the list of values. This is necessary because some non-compliant IdPs
179
183
# have been known, for example, to assert the value of eduPersonPrincipalName
180
184
# in the value for SAML2 persistent NameID as well as asserting
181
185
# eduPersonPrincipalName.
182
- if nameid_value not in values :
183
- satosa_logging (logger , logging .DEBUG , "Added NameID {} to candidate values" .format (nameid_value ), context .state )
184
- values .append (nameid_value )
186
+ if candidate_nameid_value not in values :
187
+ satosa_logging (logger , logging .DEBUG , "Added NameID {} to candidate values" .format (candidate_nameid_value ), context .state )
188
+ values .append (candidate_nameid_value )
185
189
else :
186
- satosa_logging (logger , logging .WARN , "NameID {} value also asserted as attribute value" .format (nameid_value ), context .state )
190
+ satosa_logging (logger , logging .WARN , "NameID {} value also asserted as attribute value" .format (candidate_nameid_value ), context .state )
187
191
188
192
# If no value was asserted by the IdP for one of the configured list of identifier names
189
193
# for this candidate then go onto the next candidate.
@@ -341,11 +345,11 @@ def _populate_input_for_name_id(self, config, record, context, data):
341
345
context .state
342
346
)
343
347
else :
344
- data .user_id = user_id
348
+ data .subject_id = user_id
345
349
satosa_logging (
346
350
logger ,
347
351
logging .DEBUG ,
348
- "Input for NameID is {}" .format (data .user_id ),
352
+ "Input for NameID is {}" .format (data .subject_id ),
349
353
context .state
350
354
)
351
355
0 commit comments