read configs from env
This commit is contained in:
@@ -9,6 +9,8 @@ import importlib
|
||||
import requests
|
||||
from threading import Lock
|
||||
|
||||
import env_provider
|
||||
|
||||
_public_key_cache = None
|
||||
_lock = Lock()
|
||||
|
||||
@@ -20,7 +22,7 @@ def keycloak_public_key():
|
||||
if _public_key_cache:
|
||||
return _public_key_cache
|
||||
|
||||
url = "https://login.hangman-lab.top/realms/Hangman-Lab/protocol/openid-connect/certs"
|
||||
url = f"{env_provider.KC_HOST}/realms/{env_provider.KC_REALM}/protocol/openid-connect/certs"
|
||||
response = requests.get(url)
|
||||
jwks = response.json()
|
||||
public_key = jwks["keys"][0]["x5c"][0]
|
||||
@@ -33,7 +35,7 @@ def verify_token(token):
|
||||
token,
|
||||
keycloak_public_key(),
|
||||
algorithms=["RS256"],
|
||||
audience="labdev"
|
||||
audience=env_provider.KC_CLIENT_ID
|
||||
)
|
||||
return decoded
|
||||
except ExpiredSignatureError:
|
||||
|
||||
Reference in New Issue
Block a user