Skip to content

Commit

Permalink
Patch 'get_all_shib_idps' to handling bad input (#917)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulineribeyre committed May 25, 2021
1 parent 041b4e1 commit ca8281c
Showing 1 changed file with 23 additions and 7 deletions.
30 changes: 23 additions & 7 deletions fence/blueprints/login/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,13 +321,29 @@ def get_all_shib_idps():
assert (
res.status_code == 200
), "Unable to get list of Shibboleth IDPs from {}".format(url)
return [
{
"idp": shib_idp["entityID"],
"name": get_shib_idp_en_name(shib_idp["DisplayNames"]),
}
for shib_idp in res.json()
]

all_shib_idps = []
for shib_idp in res.json():
if "entityID" not in shib_idp:
logger.warn(
f"get_all_shib_idps(): 'entityID' field not in IDP data: {shib_idp}. Skipping this IDP."
)
continue
idp = shib_idp["entityID"]
if len(shib_idp.get("DisplayNames", [])) > 0:
name = get_shib_idp_en_name(shib_idp["DisplayNames"])
else:
logger.warn(
f"get_all_shib_idps(): 'DisplayNames' field not in IDP data: {shib_idp}. Using IDP ID '{idp}' as IDP name."
)
name = idp
all_shib_idps.append(
{
"idp": idp,
"name": name,
}
)
return all_shib_idps


def get_shib_idp_en_name(names):
Expand Down

0 comments on commit ca8281c

Please sign in to comment.