make signature algorithm configurable (#7)

This commit is contained in:
Shuchang Zheng
2024-03-03 17:01:14 -05:00
committed by GitHub
parent 6f7eb006d5
commit 2123b2da31
2 changed files with 9 additions and 3 deletions

View File

@@ -5,10 +5,9 @@ from typing import Any, Union
from jose import jwt
from skyvern.config import settings
from skyvern.forge.sdk.settings_manager import SettingsManager
ALGORITHM = "HS256"
def create_access_token(
subject: Union[str, Any],
@@ -21,7 +20,11 @@ def create_access_token(
minutes=SettingsManager.get_settings().ACCESS_TOKEN_EXPIRE_MINUTES,
)
to_encode = {"exp": expire, "sub": str(subject)}
encoded_jwt = jwt.encode(to_encode, SettingsManager.get_settings().SECRET_KEY, algorithm=ALGORITHM)
encoded_jwt = jwt.encode(
to_encode,
SettingsManager.get_settings().SECRET_KEY,
algorithm=settings.SIGNATURE_ALGORITHM,
)
return encoded_jwt