Skip to content

Commit

Permalink
Adjust pem logic
Browse files Browse the repository at this point in the history
  • Loading branch information
MelissaAutumn committed May 1, 2024
1 parent e4227e5 commit 9e202ab
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions backend/src/appointment/dependencies/fxa.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,14 @@ def get_webhook_auth(request: Request, fxa_client: FxaClient = Depends(get_fxa_c
jwk_pem = None
for current_jwk in public_jwks:
if current_jwk.get('kid') == headers.get('kid'):
jwk_obj = jwt.PyJWK(current_jwk)
jwk_pem = jwk_obj.Algorithm.prepare_key(jwk_obj.key)
jwk_pem = jwt.PyJWK(current_jwk).key
break

if jwk_pem is None:
logging.error(f"Error decoding token. Key ID ({headers.get('kid')}) is missing from public list.")
return None

decoded_jwt = jwt.decode(header_token, jwk_pem, audience=fxa_client.client_id, algorithms='RS256')
decoded_jwt = jwt.decode(header_token, key=jwk_pem, audience=fxa_client.client_id, algorithms='RS256')

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

0 comments on commit 9e202ab

Please sign in to comment.