fix(packs-lab): 일회성 토큰 jti 영속화 (SQLite) — 재시작 replay 방어 유지
인메모리 _used_jti set은 컨테이너 재시작 시 비워져 TTL 내 토큰 replay가 가능했음(webhook 배포가 잦아 실재 구멍). 영속 볼륨(PACK_BASE_DIR)의 jti_store.db에 사용 jti를 기록(PK 원자성), 만료 항목은 lazy 정리. verify_upload_token이 jti_store.consume 사용. TDD 3 + 기존 replay 테스트 보존. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -14,3 +14,10 @@ def _hmac_secret(monkeypatch):
|
||||
# auth.py 모듈은 import 시점에 _SECRET을 캐시하므로 monkeypatch로 함께 갱신
|
||||
from app import auth
|
||||
monkeypatch.setattr(auth, "_SECRET", secret)
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def _isolate_jti_db(tmp_path, monkeypatch):
|
||||
"""jti 영속 저장소를 테스트별 tmp 파일로 격리 (verify_upload_token이 consume하므로)."""
|
||||
from app import jti_store
|
||||
monkeypatch.setattr(jti_store, "JTI_DB_PATH", str(tmp_path / "jti.db"))
|
||||
|
||||
Reference in New Issue
Block a user