add: webhook
This commit is contained in:
@@ -41,20 +41,19 @@ def get_jwks():
|
||||
|
||||
def get_public_key_for_kid(kid):
|
||||
global _public_key_cache
|
||||
if kid in _public_key_cache:
|
||||
return _public_key_cache[kid]
|
||||
jwks = get_jwks()
|
||||
res = []
|
||||
for key_data in jwks["keys"]:
|
||||
if key_data["kid"] == kid and key_data["use"] == "sig" and key_data["alg"] == "RS256" and key_data["kty"] == "RSA":
|
||||
x5c = key_data["x5c"][0]
|
||||
pem_public_key = x5c_to_public_key(x5c)
|
||||
_public_key_cache[kid] = pem_public_key
|
||||
res.append(pem_public_key)
|
||||
if len(res) > 0:
|
||||
print(len(res))
|
||||
return res[0]
|
||||
|
||||
with _lock:
|
||||
if kid in _public_key_cache:
|
||||
return _public_key_cache[kid]
|
||||
jwks = get_jwks()
|
||||
res = []
|
||||
for key_data in jwks["keys"]:
|
||||
if key_data["kid"] == kid and key_data["use"] == "sig" and key_data["alg"] == "RS256" and key_data["kty"] == "RSA":
|
||||
x5c = key_data["x5c"][0]
|
||||
pem_public_key = x5c_to_public_key(x5c)
|
||||
_public_key_cache[kid] = pem_public_key
|
||||
res.append(pem_public_key)
|
||||
if len(res) > 0:
|
||||
return res[0]
|
||||
return None
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user