fix: critical security improvements

- Apply optimistic locking to deposit-matcher.ts (race condition fix)
- Add timing-safe comparison for API key validation
- Move admin IDs from wrangler.toml vars to secrets
- Add .env.example for secure credential management

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
kappa
2026-01-21 17:18:21 +09:00
parent 8edab3069f
commit 91f50ddc12
6 changed files with 82 additions and 37 deletions

View File

@@ -9,8 +9,7 @@ binding = "AI"
SUMMARY_THRESHOLD = "20" # 프로필 업데이트 주기 (메시지 수)
MAX_SUMMARIES_PER_USER = "3" # 유지할 프로필 버전 수 (슬라이딩 윈도우)
N8N_WEBHOOK_URL = "https://n8n.anvil.it.com" # n8n 연동 (선택)
DOMAIN_OWNER_ID = "821596605" # 도메인 관리 권한 Telegram ID
DEPOSIT_ADMIN_ID = "821596605" # 예치금 관리 권한 Telegram ID
# Admin IDs moved to secrets (see bottom of file)
# API Endpoints
OPENAI_API_BASE = "https://gateway.ai.cloudflare.com/v1/d8e5997eb4040f8b489f09095c0f623c/telegram-bot/openai"
@@ -47,3 +46,5 @@ crons = ["0 15 * * *"] # UTC 15:00 = KST 00:00
# - NAMECHEAP_API_KEY_INTERNAL: Namecheap API 키 (내부용)
# - BRAVE_API_KEY: Brave Search API 키
# - DEPOSIT_API_SECRET: Deposit API 인증 키 (namecheap-api 연동)
# - DOMAIN_OWNER_ID: 도메인 관리 권한 Telegram ID (보안상 secrets 권장)
# - DEPOSIT_ADMIN_ID: 예치금 관리 권한 Telegram ID (보안상 secrets 권장)