Skip to content

Commit fc6e94b

Browse files
committed
using only public key for decoding jwt
1 parent 9c8dd79 commit fc6e94b

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

encryption_jwt/codec_server.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import requests
77
from aiohttp import hdrs, web
88
from google.protobuf import json_format
9+
from jwt import PyJWK
910
from jwt.algorithms import RSAAlgorithm
1011
from temporalio.api.cloud.cloudservice.v1 import GetUsersRequest
1112
from temporalio.api.common.v1 import Payloads
@@ -90,20 +91,20 @@ async def handler(req: web.Request):
9091
jwks = requests.get(jwks_url).json()
9192

9293
# Extract Temporal Cloud's public key
93-
public_key = None
94+
pyjwk = None
9495
for key in jwks["keys"]:
9596
if key["kid"] == kid:
9697
# Convert JWKS key to PEM format
97-
public_key = RSAAlgorithm.from_jwk(key)
98+
pyjwk = PyJWK.from_dict(key)
9899
break
99100

100-
if public_key is None:
101+
if pyjwk is None:
101102
raise ValueError("Public key not found in JWKS")
102103

103104
# Decode the jwt, verifying against Temporal Cloud's public key
104105
decoded = jwt.decode(
105106
encoded,
106-
public_key,
107+
pyjwk.key,
107108
algorithms=[algorithm],
108109
audience=[
109110
"https://saas-api.tmprl.cloud",

0 commit comments

Comments
 (0)