토큰 로직 수정

This commit is contained in:
skkim committed 2026-05-11 14:01:26 +09:00
1 parent 97a6384a54
commit 2c8c16c288
5 files changed
+40 -6

No files matched your search

+22
View File
@@ -116,6 +116,28 @@ def decode_token(token: str) -> Optional[dict]:
return None
def is_token_expired(token: str) -> bool:
"""
토큰이 만료됐는지 확인 (서명/형식은 유효하지만 exp 초과인 경우)
Returns:
True: 서명은 유효하나 만료된 토큰, False: 형식/서명 자체가 잘못된 토큰
"""
try:
payload = jwt.decode(
token,
jwt_settings.JWT_SECRET,
algorithms=[jwt_settings.JWT_ALGORITHM],
options={"verify_exp": False},
)
exp = payload.get("exp")
if exp is None:
return False
return datetime.fromtimestamp(exp) < datetime.now()
except JWTError:
return False
def get_token_hash(token: str) -> str:
"""
토큰의 SHA-256 해시값 생성