Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/delegate.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,19 @@ def handler(event, context: LambdaContext) -> dict:
if not domains.issubset(refresh_token['domains']):
return bad_request('', 'domain requested outside refresh_token')

# Validate no commas in subject or existing sub chain to avoid join ambiguity
if ',' in subject:
return bad_request('', 'subject contains invalid comma')
existing_sub = refresh_token.get('sub', [])
if any(',' in s for s in existing_sub if isinstance(s, str)):
return bad_request('', 'existing sub chain contains invalid comma')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

als existing_sub een string is gaat dit problemen geven denk ik
[s for s in "foo"" is ["f", "o", "o"] IIRC

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

klopt. ik kijk naar een fix

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

misschien iets als

if isinstance(existing_sub, str):
    existing_sub =  existing_sub.split()

boven de if any


delegate_token = {
'iat': int(time.time()),
'exp': exp,
'domains': list(domains),
'azp': refresh_token['azp'], # Authorized Party
'sub': refresh_token.get('sub', []) + [subject], # subject
'sub': ', '.join(existing_sub + [subject]), # sub must be string adhering to jwt spec: https://datatracker.ietf.org/doc/html/rfc7519#section-4.1.2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ik zou , zonder spatie gebruiken, is iets eenvoudiger in de split

}
logger.info({"message": "Issuing JWT", "jwt": delegate_token})
raw_delegate_token = jwt.encode(
Expand Down
1 change: 1 addition & 0 deletions src/use_grant.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def handler(event, context) -> dict:
raw_grant,
get_grant_jwt_secret(),
algorithms=['HS256'],
options={'require': [], 'verify_sub': False}, # Disable validation for now until sub field are all strings.
)
assert 'exp' in grant
assert 'azp' in grant
Expand Down