Skip to content

Commit b32fe90

Browse files
committed
Attribute values are optional
Signed-off-by: Ivan Kanakarakis <[email protected]>
1 parent 79ae711 commit b32fe90

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

src/saml2/assertion.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,9 @@ def _match_attr_name(attr, ava):
110110

111111

112112
def _apply_attr_value_restrictions(attr, res, must=False):
113-
try:
114-
values = [av["text"] for av in attr["attribute_value"]]
115-
except KeyError:
116-
values = []
113+
values = [
114+
av["text"] for av in attr.get("attribute_value", [])
115+
]
117116

118117
try:
119118
res[_fn].extend(_filter_values(ava[_fn], values))

src/saml2/mdstore.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1379,13 +1379,15 @@ def entity_attributes(self, entity_id):
13791379
ext = self.__getitem__(entity_id)["extensions"]
13801380
except KeyError:
13811381
return res
1382+
13821383
for elem in ext["extension_elements"]:
1383-
if elem["__class__"] == classnames["mdattr_entityattributes"]:
1384-
for attr in elem["attribute"]:
1385-
if attr["name"] not in res:
1386-
res[attr["name"]] = []
1387-
res[attr["name"]] += [v["text"] for v in attr[
1388-
"attribute_value"]]
1384+
if elem["__class__"] != classnames["mdattr_entityattributes"]:
1385+
continue
1386+
for attr in elem["attribute"]:
1387+
res[attr["name"]] = [
1388+
*res.get(attr["name"], []),
1389+
*(v["text"] for v in attr.get("attribute_value", []))
1390+
]
13891391
return res
13901392

13911393
def supported_algorithms(self, entity_id):

0 commit comments

Comments
 (0)