Browse Source

Fix token expiry miscalculation (#24639)

tags/1.8.1
Yongtao Huang 2 months ago
parent
commit
bb718acadf
No account linked to committer's email address

+ 1
- 1
api/extensions/ext_storage.py View File

@@ -65,7 +65,7 @@ class Storage:
from extensions.storage.volcengine_tos_storage import VolcengineTosStorage

return VolcengineTosStorage
case StorageType.SUPBASE:
case StorageType.SUPABASE:
from extensions.storage.supabase_storage import SupabaseStorage

return SupabaseStorage

+ 1
- 1
api/extensions/storage/storage_type.py View File

@@ -14,4 +14,4 @@ class StorageType(StrEnum):
S3 = "s3"
TENCENT_COS = "tencent-cos"
VOLCENGINE_TOS = "volcengine-tos"
SUPBASE = "supabase"
SUPABASE = "supabase"

+ 0
- 4
api/factories/variable_factory.py View File

@@ -128,10 +128,6 @@ def _build_variable_from_mapping(*, mapping: Mapping[str, Any], selector: Sequen
return cast(Variable, result)


def infer_segment_type_from_value(value: Any, /) -> SegmentType:
return build_segment(value).value_type


def build_segment(value: Any, /) -> Segment:
# NOTE: If you have runtime type information available, consider using the `build_segment_with_type`
# below

+ 5
- 5
api/libs/helper.py View File

@@ -301,8 +301,8 @@ class TokenManager:
if expiry_minutes is None:
raise ValueError(f"Expiry minutes for {token_type} token is not set")
token_key = cls._get_token_key(token, token_type)
expiry_time = int(expiry_minutes * 60)
redis_client.setex(token_key, expiry_time, json.dumps(token_data))
expiry_seconds = int(expiry_minutes * 60)
redis_client.setex(token_key, expiry_seconds, json.dumps(token_data))

if account_id:
cls._set_current_token_for_account(account_id, token, token_type, expiry_minutes)
@@ -336,11 +336,11 @@ class TokenManager:

@classmethod
def _set_current_token_for_account(
cls, account_id: str, token: str, token_type: str, expiry_hours: Union[int, float]
cls, account_id: str, token: str, token_type: str, expiry_minutes: Union[int, float]
):
key = cls._get_account_token_key(account_id, token_type)
expiry_time = int(expiry_hours * 60 * 60)
redis_client.setex(key, expiry_time, token)
expiry_seconds = int(expiry_minutes * 60)
redis_client.setex(key, expiry_seconds, token)

@classmethod
def _get_account_token_key(cls, account_id: str, token_type: str) -> str:

Loading…
Cancel
Save