Add AI receipt scanning with OCR pipeline and debug toggle
- OCR pipeline: Tesseract (images) + pdfplumber (PDFs) → AI text prompt → rule-based regex fallback; works with any text model, not just vision models - Scan Receipt toolbar button parses a photo and pre-fills the transaction form; receipt image is automatically attached to the created transaction - AI settings page: provider, API key (AES-256-GCM encrypted), custom URL, model, and per-user debug toggle that gates the OCR/AI debug panel - Fix CSRF cookie secure=False so HTTP deployments work; add 7-day max_age - Fix attachment_refs missing from _to_response (attachments never appeared in UI) - Fix multipart boundary lost when Content-Type was set manually in axios calls - nginx: raise client_max_body_size to 15 MB, add 120s proxy timeout for OCR - Migration 0005: add ai_debug boolean to users table - Update README and CLAUDE.md with AI scanning docs and architecture notes Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
a7c54ca61c
commit
26e2a055db
16 changed files with 397 additions and 99 deletions
|
|
@ -7,7 +7,6 @@ from fastapi import Request, Response
|
|||
from starlette.middleware.base import BaseHTTPMiddleware
|
||||
from starlette.responses import JSONResponse
|
||||
|
||||
from app.config import get_settings
|
||||
|
||||
SAFE_METHODS = {"GET", "HEAD", "OPTIONS"}
|
||||
|
||||
|
|
@ -57,7 +56,8 @@ class CSRFMiddleware(BaseHTTPMiddleware):
|
|||
"csrf_token", token,
|
||||
httponly=False, # must be readable by JS
|
||||
samesite="lax",
|
||||
secure=not get_settings().is_development,
|
||||
secure=False, # CSRF token is public by design; Secure would break HTTP deployments
|
||||
max_age=604800, # 7 days — survive browser restarts
|
||||
)
|
||||
return response
|
||||
|
||||
|
|
@ -65,7 +65,7 @@ class CSRFMiddleware(BaseHTTPMiddleware):
|
|||
response = await call_next(request)
|
||||
if not existing_csrf:
|
||||
token = str(uuid.uuid4())
|
||||
response.set_cookie("csrf_token", token, httponly=False, samesite="lax", secure=not get_settings().is_development)
|
||||
response.set_cookie("csrf_token", token, httponly=False, samesite="lax", secure=False, max_age=604800)
|
||||
return response
|
||||
|
||||
if request.url.path in {"/api/v1/auth/login", "/api/v1/auth/login/totp"}:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue