feat: implement user authentication module

- Backend (FastAPI):
  - External API authentication (pj-auth-api.vercel.app)
  - JWT token validation with Redis session storage
  - RBAC with department isolation
  - User, Role, Department models with pjctrl_ prefix
  - Alembic migrations with project-specific version table
  - Complete test coverage (13 tests)

- Frontend (React + Vite):
  - AuthContext for state management
  - Login page with error handling
  - Protected route component
  - Dashboard with user info display

- OpenSpec:
  - 7 capability specs defined
  - add-user-auth change archived

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
beabigegg
2025-12-28 23:41:37 +08:00
commit 1fda7da2c2
77 changed files with 6562 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
1. 系統架構 (System Architecture)
採用三層式架構 (3-Tier Architecture) 以確保未來擴展性(如未來可對接 MES/ERP 數據)。
前端 (Presentation Layer) React.js 或 Vue.js (推薦 React其生態系在處理複雜管理後台較成熟)。
後端 (Application Layer) Python (FastAPI) Python 方便未來導入 AI 風險預測與數據分析。
數據層 (Data Layer) * 主資料庫: mysql (關聯式結構最適合處理專案間的複雜層級與相依性)。
快取與即時通訊: Redis (用於即時通知推播與任務狀態鎖定)。
2. 核心數據模型設計 (ERD Concept)
User: ID, Name, Department, Role, Skills, Capacity.
Project: ID, Title, Owner, Budget, Timeline, Security_Level.
Task: ID, Project_ID, Assignee, Priority, Status, Original_Estimate, Time_Spent, Blocker_Flag.
Attachment: ID, Task_ID, Version, File_Path (支援地端 NAS 存儲)。
3. 關鍵技術功能設計
即時同步 (Real-time Sync) 使用 WebSocket當多人同時編輯同一個專案看板時狀態能即時更新而不需刷新頁面。
文件加密: 針對半導體敏感圖檔,存儲層進行 AES-256 加密,且下載時自動加上使用者浮水印。
整合介面 (Integrations)
SSO 整合企業內部 Windows AD。(使用https://pj-auth-api.vercel.app)