File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -104,12 +104,22 @@ 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 new subject to avoid future join ambiguity
108+ if ',' in subject :
109+ return bad_request ('' , 'subject contains invalid comma' )
110+
111+ existing_sub = refresh_token .get ('sub' , [])
112+ if isinstance (existing_sub , str ):
113+ existing_sub = [x .strip () for x in existing_sub .split (',' )] # Convert string to list
114+ elif isinstance (existing_sub , list ):
115+ pass # Already a list, no change needed
116+
107117 delegate_token = {
108118 'iat' : int (time .time ()),
109119 'exp' : exp ,
110120 'domains' : list (domains ),
111121 'azp' : refresh_token ['azp' ], # Authorized Party
112- 'sub' : refresh_token . get ( 'sub' , []) + [subject ], # subject
122+ 'sub' : ',' . join ( existing_sub + [subject ]) , # sub must be string adhering to jwt spec: https://datatracker.ietf.org/doc/html/rfc7519#section-4.1.2
113123 }
114124 logger .info ({"message" : "Issuing JWT" , "jwt" : delegate_token })
115125 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