Skip to content

Commit b392203

Browse files
committed
warn when trust info has profiles with same name. Also allow extra metadata in trust info in entity attribute.
1 parent f733b10 commit b392203

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/pyff/samlmd.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1048,18 +1048,27 @@ def discojson_sp_attr(e):
10481048
return None
10491049

10501050
entityID = e.get('entityID', None)
1051-
if entityID is None:
1052-
return None
1053-
10541051
sp = {}
10551052
sp['entityID'] = entityID
10561053
sp['profiles'] = {}
1054+
sp['extra_md'] = {}
10571055

10581056
for b64_trustinfo in b64_trustinfos:
10591057
try:
10601058
str_trustinfo = b64decode(b64_trustinfo.encode('ascii'))
10611059
trustinfo = json.loads(str_trustinfo.decode('utf8'))
1062-
sp['profiles'].update(trustinfo['profiles'])
1060+
for profile in trustinfo['profiles']:
1061+
if profile in sp['profiles']:
1062+
log.warning(f"SP Entity {entityID} has a duplicate trust profile {profile}")
1063+
else:
1064+
sp['profiles'][profile] = trustinfo['profiles'][profile]
1065+
1066+
if 'extra_md' in trustinfo:
1067+
for extra_id in trustinfo['extra_md']:
1068+
if extra_id in sp['extra_md']:
1069+
log.warning(f"SP Entity {entityID} has a duplicate extra IdP metadata {extra_id}")
1070+
else:
1071+
sp['extra_md'][extra_id] = trustinfo['extra_md'][extra_id]
10631072

10641073
except Exception as e:
10651074
log.warning(f"Invalid entity-selection-profile attribute for {entityID}: {e}")

0 commit comments

Comments
 (0)