2026-04-13 09:56:30 +07:00
|
|
|
# Story 1.2: Triển khai Backend API Xác thực & JWT (Backend Auth API & JWT)
|
|
|
|
|
|
|
|
|
|
**Status:** done
|
|
|
|
|
**Epic:** Epic 1
|
|
|
|
|
**Story Key:** `1-2-backend-auth-api-jwt`
|
|
|
|
|
|
|
|
|
|
## 📖 Story Requirements (Context & PRD)
|
|
|
|
|
> This section maps directly to the original Product Requirements Document and Epics definition.
|
|
|
|
|
|
|
|
|
|
As a Người dùng,
|
2026-04-13 23:17:12 +07:00
|
|
|
I want gọi API an toàn để tạo tài khoản, đăng nhập và lấy mã Token (JWT) theo chuẩn quy ước OAuth2,
|
|
|
|
|
So that hệ thống xác thực được danh tính của tôi và định danh xử lý xác thực qua API backend.
|
2026-04-13 09:56:30 +07:00
|
|
|
**Acceptance Criteria:**
|
|
|
|
|
**Given** thông tin đăng nhập hợp lệ
|
2026-04-13 23:17:12 +07:00
|
|
|
**When** gửi request form data tới endpoint `/auth/jwt/login`
|
|
|
|
|
**Then** hệ thống trả về cấu trúc token dạng OAuth2 Bearer: `{"access_token": "xxx", "refresh_token": "xxx", "token_type": "bearer"}`
|
|
|
|
|
**And** Định danh dữ liệu bảo mật được gắn kết thông qua ORM Filters và Zero-cache access rules thay vì Postgres RLS thuần túy.
|
2026-04-13 09:56:30 +07:00
|
|
|
|
|
|
|
|
## 🏗️ Architecture & Technical Guardrails
|
|
|
|
|
> Critical instructions for the development agent based on the project's established architecture.
|
|
|
|
|
|
|
|
|
|
### Technical Requirements
|
|
|
|
|
- Language/Framework: React, Next.js (TypeScript) for Web; FastAPI (Python) for Backend.
|
|
|
|
|
- Database: Prisma/Supabase.
|
|
|
|
|
- Strict Type checking must be enforced. No `any` types.
|
|
|
|
|
|
|
|
|
|
### Code Organization
|
|
|
|
|
This story is currently marked as `done`. Implementation should target the following components/files:
|
|
|
|
|
|
2026-04-13 23:17:12 +07:00
|
|
|
*(Files to be determined during implementation)*
|
2026-04-13 09:56:30 +07:00
|
|
|
|
|
|
|
|
### Developer Agent Constraints
|
|
|
|
|
1. **No Destructive Refactors**: Extend existing modules when possible.
|
|
|
|
|
2. **Context Check**: Always refer back to `task.md` and use Context7 to verify latest SDK usages.
|
|
|
|
|
3. **BMad Standard**: Update the sprint status using standard metrics.
|
|
|
|
|
|
|
|
|
|
## 🧪 Testing & Validation Requirements
|
|
|
|
|
- All new endpoints must be tested.
|
|
|
|
|
- Frontend components should gracefully degrade.
|
|
|
|
|
- Do not introduce regressions into existing user workflows.
|
|
|
|
|
|
|
|
|
|
## 📈 Completion Status
|
|
|
|
|
*(To be updated by the agent when completing this story)*
|
|
|
|
|
- Start Date: _____________
|
|
|
|
|
- Completion Date: _____________
|
|
|
|
|
- Key Files Changed:
|
|
|
|
|
-
|
|
|
|
|
|