Auth

Xác thực & API Keys

Backend hỗ trợ 2 lớp key: Master key (admin) và User key (per-user). User key được tạo trong trang /account sau khi đăng nhập Google (Supabase). Backend lưu SHA-256 hash của key trong SQLite (Lite mode mặc định), hỗ trợ revoke và audit last_used_at.

Master key
Dùng cho nội bộ/ops. Backend hiện dùng prefix lcAi_.
Authorization: Bearer lcAi_<MASTER_KEY>
User key
Dùng cho developer và per-tenant quota/rate-limit sau này. Backend dùng prefix lcAi_u_.
Authorization: Bearer lcAi_u_<USER_KEY>
SSE streaming
curl -N http://127.0.0.1:9999/api/chat/stream \
  -H "Authorization: Bearer lcAi_u_<USER_KEY>" \
  -H "Content-Type: application/json" \
  -d '{"message":"Soạn công văn đôn đốc nợ","conversation_id":"stream_001"}'
Deploy troubleshooting (Vercel/GitHub)
Nếu check Vercel báo lỗi “No GitHub account was found matching the commit author email address”, xử lý theo 1 trong các cách sau:
  • Đảm bảo commits được tạo với git config user.email = email đã verify trên GitHub (vd locaithsolution@locaith.com) rồi commit lại (hoặc squash/rebase).
  • Hoặc thêm email đang bị lệch vào GitHub account và verify nó.
  • Nếu dùng GitHub “noreply” email thì set đúng noreply email đó cho git.