feat: Phase 1 - Complete authentication system with JWT
Backend Implementation (FastAPI + MongoDB): - JWT authentication with access/refresh tokens - User registration and login endpoints - Password hashing with bcrypt (fixed 72-byte limit) - Protected endpoints with JWT middleware - Token refresh mechanism - Role-Based Access Control (RBAC) structure - Pydantic v2 models and async MongoDB with Motor - API endpoints: /api/auth/register, /api/auth/login, /api/auth/me, /api/auth/refresh Frontend Implementation (React + TypeScript + Material-UI): - Login and Register pages with validation - AuthContext for global authentication state - API client with Axios interceptors for token refresh - Protected routes with automatic redirect - User profile display in navigation - Logout functionality Technical Achievements: - Resolved bcrypt 72-byte limit (replaced passlib with native bcrypt) - Fixed Pydantic v2 compatibility (PyObjectId, ConfigDict) - Implemented automatic token refresh on 401 errors - Created comprehensive test suite for all auth endpoints Docker & Kubernetes: - Backend image: yakenator/site11-console-backend:latest - Frontend image: yakenator/site11-console-frontend:latest - Deployed to site11-pipeline namespace - Nginx reverse proxy configuration Documentation: - CONSOLE_ARCHITECTURE.md - Complete system architecture - PHASE1_COMPLETION.md - Detailed completion report - PROGRESS.md - Updated with Phase 1 status All authentication endpoints tested and verified working. 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
0
services/console/backend/app/db/__init__.py
Normal file
0
services/console/backend/app/db/__init__.py
Normal file
37
services/console/backend/app/db/mongodb.py
Normal file
37
services/console/backend/app/db/mongodb.py
Normal file
@ -0,0 +1,37 @@
|
||||
from motor.motor_asyncio import AsyncIOMotorClient, AsyncIOMotorDatabase
|
||||
from typing import Optional
|
||||
from ..core.config import settings
|
||||
|
||||
|
||||
class MongoDB:
|
||||
"""MongoDB connection manager"""
|
||||
|
||||
client: Optional[AsyncIOMotorClient] = None
|
||||
db: Optional[AsyncIOMotorDatabase] = None
|
||||
|
||||
@classmethod
|
||||
async def connect(cls):
|
||||
"""Connect to MongoDB"""
|
||||
cls.client = AsyncIOMotorClient(settings.MONGODB_URL)
|
||||
cls.db = cls.client[settings.DB_NAME]
|
||||
print(f"✅ Connected to MongoDB: {settings.DB_NAME}")
|
||||
|
||||
@classmethod
|
||||
async def disconnect(cls):
|
||||
"""Disconnect from MongoDB"""
|
||||
if cls.client:
|
||||
cls.client.close()
|
||||
print("❌ Disconnected from MongoDB")
|
||||
|
||||
@classmethod
|
||||
def get_db(cls) -> AsyncIOMotorDatabase:
|
||||
"""Get database instance"""
|
||||
if cls.db is None:
|
||||
raise Exception("Database not initialized. Call connect() first.")
|
||||
return cls.db
|
||||
|
||||
|
||||
# Convenience function
|
||||
async def get_database() -> AsyncIOMotorDatabase:
|
||||
"""Dependency to get database"""
|
||||
return MongoDB.get_db()
|
||||
Reference in New Issue
Block a user