feat: Initial commit - Task Reporter incident response system
Complete implementation of the production line incident response system (生產線異常即時反應系統) including: Backend (FastAPI): - User authentication with AD integration and session management - Chat room management (create, list, update, members, roles) - Real-time messaging via WebSocket (typing indicators, reactions) - File storage with MinIO (upload, download, image preview) Frontend (React + Vite): - Authentication flow with token management - Room list with filtering, search, and pagination - Real-time chat interface with WebSocket - File upload with drag-and-drop and image preview - Member management and room settings - Breadcrumb navigation - 53 unit tests (Vitest) Specifications: - authentication: AD auth, sessions, JWT tokens - chat-room: rooms, members, templates - realtime-messaging: WebSocket, messages, reactions - file-storage: MinIO integration, file management - frontend-core: React SPA structure 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
31
app/modules/auth/models.py
Normal file
31
app/modules/auth/models.py
Normal file
@@ -0,0 +1,31 @@
|
||||
"""SQLAlchemy models for authentication
|
||||
|
||||
資料表結構:
|
||||
- user_sessions: 儲存使用者 session 資料,包含加密密碼用於自動刷新
|
||||
"""
|
||||
from sqlalchemy import Column, Integer, String, DateTime, Index
|
||||
from datetime import datetime
|
||||
from app.core.database import Base
|
||||
|
||||
|
||||
class UserSession(Base):
|
||||
"""User session model with encrypted password for auto-refresh"""
|
||||
|
||||
__tablename__ = "user_sessions"
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
username = Column(String(255), nullable=False, comment="User email from AD")
|
||||
display_name = Column(String(255), nullable=False, comment="Display name for chat")
|
||||
internal_token = Column(
|
||||
String(255), unique=True, nullable=False, index=True, comment="Internal session token (UUID)"
|
||||
)
|
||||
ad_token = Column(String(500), nullable=False, comment="AD API token")
|
||||
encrypted_password = Column(String(500), nullable=False, comment="AES-256 encrypted password")
|
||||
ad_token_expires_at = Column(DateTime, nullable=False, comment="AD token expiry time")
|
||||
refresh_attempt_count = Column(
|
||||
Integer, default=0, nullable=False, comment="Failed refresh attempts counter"
|
||||
)
|
||||
last_activity = Column(
|
||||
DateTime, default=datetime.utcnow, nullable=False, comment="Last API request time"
|
||||
)
|
||||
created_at = Column(DateTime, default=datetime.utcnow, nullable=False)
|
||||
Reference in New Issue
Block a user