Skip to Content
Security

Security

Security model for the Personal Finances system. Single-user, private use.


Authentication

  • Provider: Supabase Auth (email + password)
  • Session: JWT stored in HTTP-only cookies via @supabase/ssr
  • User creation: Only via seed script — no public registration endpoint
  • Token lifetime: Managed by Supabase (auto-refresh via SSR middleware)

All frontend API calls include Authorization: Bearer <jwt> in the request header. The backend validates the JWT on every /api/v2/* request.


Telegram Bot Access Control

ControlImplementation
Webhook secretX-Telegram-Bot-Api-Secret-Token header validated on every incoming update
Chat ID restrictionAll messages from chat IDs other than TELEGRAM_ALLOWED_CHAT_ID are silently ignored
HTTPS onlyTelegram Bot API requires HTTPS for webhook URLs

Backend Hardening

MeasureDetail
OpenAPI hidden in productionopenapi_url=None when ENVIRONMENT=production (default). Set ENVIRONMENT=development to expose /openapi.json.
Rate limiting30 req/min per IP on /webhook
CORSAccepts only *.nathanfiorito.com.br origins
Service key isolationSupabase service key used only in backend — never exposed to frontend
No hard deletes on categoriesDeactivation preserves data integrity

Environment Variables (sensitive)

Never commit these values. Store in .env (local) and Render / Vercel environment settings (production).

VariableUsed BySecret Level
TELEGRAM_BOT_TOKENBackendHigh
TELEGRAM_WEBHOOK_SECRETBackendHigh
TELEGRAM_ALLOWED_CHAT_IDBackendMedium
OPENROUTER_API_KEYBackendHigh
SUPABASE_URLBackend + FrontendLow
SUPABASE_SERVICE_KEYBackend onlyHigh
SUPABASE_ANON_KEYFrontend onlyLow
Last updated on