Phase 8 Complete: Sync Audit Log + Frontend Integration

- Thêm audit/sync_audit.py: Ghi lịch sử sync vào audit/sync_log.json
- Thêm API endpoints: /sync/history, /sync/history/{run_id}
- Frontend: Nút 'Lịch sử đồng bộ' + panel expand chi tiết từng file
- Sửa frontend served từ backend (http://localhost:8000)
- Cập nhật DEPLOYMENT_GUIDE với hướng dẫn chạy localhost
- Cập nhật ARCHITECTURE_MAP: Phase 8 hoàn thành
This commit is contained in:
2026-05-11 08:49:10 +00:00
parent f937d1a98e
commit 78372d18ee
8 changed files with 577 additions and 18 deletions

View File

@@ -4,6 +4,42 @@
---
## 0. Chạy hệ thống trên Localhost
### Yêu cầu
- Python 3.10+ với venv đã cài dependencies
- Docker (cho OpenSearch)
- Azure AD App Registration đã cấu hình
### Các bước khởi động
```bash
# 1. Khởi động OpenSearch
docker-compose up -d opensearch
# 2. Khởi động Backend (serves cả API + Frontend)
source venv/bin/activate
python3 api/main.py
# 3. Mở trình duyệt
# http://localhost:8000
```
### Truy cập
| URL | Mô tả |
|-----|-------|
| `http://localhost:8000` | Frontend (Login + Chat) |
| `http://localhost:8000/docs` | Swagger API Documentation |
| `http://localhost:8000/health` | Health check |
| `http://localhost:8000/auth/login` | SSO Azure AD redirect |
### Đăng nhập
- **SSO:** Bấm "Đăng nhập Microsoft SSO" → đăng nhập bằng tài khoản Microsoft 365
- **Email:** Nhập email bất kỳ (fallback, không cần password)
---
## 1. Cấu hình Azure AD App Registration (MANUAL)
### 1.1 Tạo App Registration (nếu chưa có)
@@ -36,13 +72,13 @@
4. Bấm **Add permissions**
5. **Quan trọng:** Bấm **Grant admin consent for [tenant]** → Confirm
### 1.4 Cấu hình Redirect URI cho SSO (khi cần login)
### 1.4 Cấu hình Redirect URI cho SSO ✅ ĐÃ CẤU HÌNH
1. App Registration → **Authentication****Add a platform****Web**
2. Nhập Redirect URI:
- **PoC (localhost):** `http://localhost:8000/auth/callback`
- **Production:** `https://your-domain.com/auth/callback`
3. Tích chọn: ✅ **ID tokens** (implicit grant)
- **PoC (localhost):** `http://localhost:8000/auth/callback`
- **Production:** `https://your-domain.com/auth/callback` (thêm khi có domain)
3. Tích chọn: ✅ **ID tokens** (implicit grant)
4. Bấm **Save**
### 1.5 Kiểm tra Token Claims
@@ -350,9 +386,11 @@ curl -X POST http://localhost:8000/chat \
## 7. Checklist trước khi Production
- [ ] Azure AD App Registration đã cấu hình đúng permissions
- [ ] Client Secret còn hạn sử dụng
- [ ] Redirect URI đã thêm cho production domain
- [x] Azure AD App Registration đã cấu hình đúng permissions
- [x] Client Secret còn hạn sử dụng
- [x] Redirect URI đã thêm cho localhost (`http://localhost:8000/auth/callback`)
- [x] ID tokens đã bật (implicit grant)
- [ ] Redirect URI cho production domain (khi có domain thật)
- [ ] OpenSearch đã đổi password mặc định
- [ ] SSL certificate đã cài đặt
- [ ] CORS đã giới hạn origins