Skip to content

Fix for issue 488 #489

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
73 changes: 37 additions & 36 deletions src/satosa/micro_services/ldap_attribute_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,7 @@ def process(self, context, data):

# Initialize an empty LDAP record. The first LDAP record found using
# the ordered # list of search filter values will be the record used.
responses = []
record = None
results = None
exp_msg = None
Expand Down Expand Up @@ -568,23 +569,23 @@ def process(self, context, data):
logger.debug(logline)
data.attributes = {}

for record in responses:
# This adapts records with different search and connection strategy
# (sync without pool), it should be tested with anonimous bind with
# message_id.
if isinstance(results, bool) and record:
record = {
"dn": record.entry_dn if hasattr(record, "entry_dn") else "",
"attributes": (
record.entry_attributes_as_dict
if hasattr(record, "entry_attributes_as_dict")
else {}
),
}

# Use a found record, if any, to populate attributes and input for
# NameID
if record:
if responses:
for record in responses:
# This adapts records with different search and connection strategy
# (sync without pool), it should be tested with anonimous bind with
# message_id.
if isinstance(results, bool) and record:
record = {
"dn": record.entry_dn if hasattr(record, "entry_dn") else "",
"attributes": (
record.entry_attributes_as_dict
if hasattr(record, "entry_attributes_as_dict")
else {}
),
}

# Use a found record, if any, to populate attributes and input for
# NameID
msg = {
"message": "Using record with DN and attributes",
"DN": record["dn"],
Expand Down Expand Up @@ -618,26 +619,26 @@ def process(self, context, data):
msg = "Added record {} to context".format(record)
logline = lu.LOG_FMT.format(id=session_id, message=msg)
logger.debug(logline)
else:
msg = "No record found in LDAP so no attributes will be added"
else:
msg = "No record found in LDAP so no attributes will be added"
logline = lu.LOG_FMT.format(id=session_id, message=msg)
logger.warning(logline)
on_ldap_search_result_empty = config["on_ldap_search_result_empty"]
if on_ldap_search_result_empty:
# Redirect to the configured URL with
# the entityIDs for the target SP and IdP used by the user
# as query string parameters (URL encoded).
encoded_sp_entity_id = urllib.parse.quote_plus(requester)
encoded_idp_entity_id = urllib.parse.quote_plus(issuer)
url = "{}?sp={}&idp={}".format(
on_ldap_search_result_empty,
encoded_sp_entity_id,
encoded_idp_entity_id,
)
msg = "Redirecting to {}".format(url)
logline = lu.LOG_FMT.format(id=session_id, message=msg)
logger.warning(logline)
on_ldap_search_result_empty = config["on_ldap_search_result_empty"]
if on_ldap_search_result_empty:
# Redirect to the configured URL with
# the entityIDs for the target SP and IdP used by the user
# as query string parameters (URL encoded).
encoded_sp_entity_id = urllib.parse.quote_plus(requester)
encoded_idp_entity_id = urllib.parse.quote_plus(issuer)
url = "{}?sp={}&idp={}".format(
on_ldap_search_result_empty,
encoded_sp_entity_id,
encoded_idp_entity_id,
)
msg = "Redirecting to {}".format(url)
logline = lu.LOG_FMT.format(id=session_id, message=msg)
logger.info(logline)
return Redirect(url)
logger.info(logline)
return Redirect(url)

msg = "Returning data.attributes {}".format(data.attributes)
logline = lu.LOG_FMT.format(id=session_id, message=msg)
Expand Down