File tree Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -104,12 +104,19 @@ 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
108+ if ',' in subject :
109+ return bad_request ('' , 'subject contains invalid comma' )
110+ 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' )
113+
107114 delegate_token = {
108115 'iat' : int (time .time ()),
109116 'exp' : exp ,
110117 'domains' : list (domains ),
111118 'azp' : refresh_token ['azp' ], # Authorized Party
112- 'sub' : refresh_token . get ( 'sub' , []) + [subject ], # subject
119+ 'sub' : ', ' . join ( existing_sub + [subject ]) , # sub must be string adhering to jwt spec: https://datatracker.ietf.org/doc/html/rfc7519#section-4.1.2
113120 }
114121 logger .info ({"message" : "Issuing JWT" , "jwt" : delegate_token })
115122 raw_delegate_token = jwt .encode (
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ def handler(event, context) -> dict:
2020 raw_grant ,
2121 get_grant_jwt_secret (),
2222 algorithms = ['HS256' ],
23+ options = {'require' : [], 'verify_sub' : False }, # Disable validation for now until sub field are all strings.
2324 )
2425 assert 'exp' in grant
2526 assert 'azp' in grant
You can’t perform that action at this time.
0 commit comments