Skip to content

Commit

Permalink
Upgrade warning to error, and fix dict.get() for fxa webhooks.
Browse files Browse the repository at this point in the history
  • Loading branch information
MelissaAutumn committed Jan 8, 2024
1 parent fbe55d7 commit ae58fd9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion backend/src/appointment/dependencies/fxa.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,6 @@ def get_webhook_auth(request: Request, fxa_client: FxaClient = Depends(get_fxa_c

# Final verification
if decoded_jwt.get('iss') != fxa_client.config.issuer:
logging.warning(f"Issuer is not valid: ({decoded_jwt.get('iss')}) vs ({fxa_client.config.issuer})")
logging.error(f"Issuer is not valid: ({decoded_jwt.get('iss')}) vs ({fxa_client.config.issuer})")

return decoded_jwt
4 changes: 2 additions & 2 deletions backend/src/appointment/routes/webhooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
def fxa_process(
request: Request,
db: Session = Depends(get_db),
decoded_token = Depends(get_webhook_auth),
decoded_token: dict = Depends(get_webhook_auth),
fxa_client: FxaClient = Depends(get_fxa_client)
):
"""Main for webhooks regarding fxa"""
Expand All @@ -27,7 +27,7 @@ def fxa_process(

fxa_client.setup(subscriber.id, subscriber.get_external_connection(models.ExternalConnectionType.fxa).token)

for event, event_data in decoded_token.get('events', default={}).items():
for event, event_data in decoded_token.get('events', {}).items():
match event:
case 'https://schemas.accounts.firefox.com/event/password-change':
# We also get `changeTime` in event_data, but let's just log them out.
Expand Down

0 comments on commit ae58fd9

Please sign in to comment.