Skip to content

Commit 12b96c4

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

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

src/satosa/micro_services/ldap_attribute_store.py

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -166,24 +166,28 @@ def _construct_filter_value(self, candidate, data):
166166
# name_id_format add the value for the NameID of that format if it was asserted by the IdP
167167
# or else add the value None.
168168
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
176180

177181
# Only add the NameID value asserted by the IdP if it is not already
178182
# in the list of values. This is necessary because some non-compliant IdPs
179183
# have been known, for example, to assert the value of eduPersonPrincipalName
180184
# in the value for SAML2 persistent NameID as well as asserting
181185
# 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)
185189
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)
187191

188192
# If no value was asserted by the IdP for one of the configured list of identifier names
189193
# for this candidate then go onto the next candidate.
@@ -341,11 +345,11 @@ def _populate_input_for_name_id(self, config, record, context, data):
341345
context.state
342346
)
343347
else:
344-
data.user_id = user_id
348+
data.subject_id = user_id
345349
satosa_logging(
346350
logger,
347351
logging.DEBUG,
348-
"Input for NameID is {}".format(data.user_id),
352+
"Input for NameID is {}".format(data.subject_id),
349353
context.state
350354
)
351355

0 commit comments

Comments
 (0)