|
|
@@ -1,11 +1,10 @@
|
|
|
import jwt
|
|
|
from jwt.exceptions import InvalidTokenError
|
|
|
|
|
|
-from opendevin.core.config import config
|
|
|
from opendevin.core.logger import opendevin_logger as logger
|
|
|
|
|
|
|
|
|
-def get_sid_from_token(token: str) -> str:
|
|
|
+def get_sid_from_token(token: str, jwt_secret: str) -> str:
|
|
|
"""Retrieves the session id from a JWT token.
|
|
|
|
|
|
Parameters:
|
|
|
@@ -16,7 +15,7 @@ def get_sid_from_token(token: str) -> str:
|
|
|
"""
|
|
|
try:
|
|
|
# Decode the JWT using the specified secret and algorithm
|
|
|
- payload = jwt.decode(token, config.jwt_secret, algorithms=['HS256'])
|
|
|
+ payload = jwt.decode(token, jwt_secret, algorithms=['HS256'])
|
|
|
|
|
|
# Ensure the payload contains 'sid'
|
|
|
if 'sid' in payload:
|
|
|
@@ -31,10 +30,10 @@ def get_sid_from_token(token: str) -> str:
|
|
|
return ''
|
|
|
|
|
|
|
|
|
-def sign_token(payload: dict[str, object]) -> str:
|
|
|
+def sign_token(payload: dict[str, object], jwt_secret: str) -> str:
|
|
|
"""Signs a JWT token."""
|
|
|
# payload = {
|
|
|
# "sid": sid,
|
|
|
# # "exp": datetime.now(timezone.utc) + timedelta(minutes=15),
|
|
|
# }
|
|
|
- return jwt.encode(payload, config.jwt_secret, algorithm='HS256')
|
|
|
+ return jwt.encode(payload, jwt_secret, algorithm='HS256')
|