Skip to content

Commit

Permalink
Add leeway
Browse files Browse the repository at this point in the history
  • Loading branch information
MelissaAutumn committed May 1, 2024
1 parent 9e202ab commit ea4720e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion backend/src/appointment/dependencies/fxa.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import logging
import os
import datetime

from fastapi import Request, Depends
#from jose import jwt, jwk
Expand Down Expand Up @@ -48,7 +49,10 @@ def get_webhook_auth(request: Request, fxa_client: FxaClient = Depends(get_fxa_c
logging.error(f"Error decoding token. Key ID ({headers.get('kid')}) is missing from public list.")
return None

decoded_jwt = jwt.decode(header_token, key=jwk_pem, audience=fxa_client.client_id, algorithms='RS256')
# Amount of time over what the iat is issued for to allow
# We were having millisecond timing issues, so this is set to a few seconds to cover for that.
leeway = datetime.timedelta(seconds=5)
decoded_jwt = jwt.decode(header_token, key=jwk_pem, audience=fxa_client.client_id, algorithms='RS256', leeway=leeway)

# Final verification
if decoded_jwt.get('iss') != fxa_client.config.issuer:
Expand Down

0 comments on commit ea4720e

Please sign in to comment.