Skip to content

Commit 23a369e

Browse files
check if the existing sub chain is already a string first.
1 parent 343bff1 commit 23a369e

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/delegate.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,17 @@ def handler(event, context: LambdaContext) -> dict:
104104
if not domains.issubset(refresh_token['domains']):
105105
return bad_request('', 'domain requested outside refresh_token')
106106

107-
# Validate no commas in subject or existing sub chain to avoid join ambiguity
107+
# Normalize and validate no commas in subject or existing sub chain to avoid join ambiguity
108108
if ',' in subject:
109109
return bad_request('', 'subject contains invalid comma')
110+
110111
existing_sub = refresh_token.get('sub', [])
111-
if any(',' in s for s in existing_sub if isinstance(s, str)):
112-
return bad_request('', 'existing sub chain contains invalid comma')
112+
if isinstance(existing_sub, str):
113+
if ',' in existing_sub:
114+
return bad_request('', 'existing sub chain string contains invalid comma')
115+
elif isinstance(existing_sub, list):
116+
if any(',' in s for s in existing_sub if isinstance(s, str)):
117+
return bad_request('', 'existing sub chain array contains invalid comma')
113118

114119
delegate_token = {
115120
'iat': int(time.time()),

0 commit comments

Comments
 (0)