This commit is contained in:
@@ -84,6 +84,7 @@ class SimpleAuthMiddleware(BaseHTTPMiddleware):
|
|||||||
"/static/", # Static files (CSS, JS)
|
"/static/", # Static files (CSS, JS)
|
||||||
"/api/movies", # Web API endpoints
|
"/api/movies", # Web API endpoints
|
||||||
"/api/series",
|
"/api/series",
|
||||||
|
"/api/episodes",
|
||||||
"/api/dashboard"
|
"/api/dashboard"
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -98,8 +99,7 @@ class SimpleAuthMiddleware(BaseHTTPMiddleware):
|
|||||||
"/manual/", # Manual scan endpoints (API access)
|
"/manual/", # Manual scan endpoints (API access)
|
||||||
"/debug/", # Debug endpoints (API access)
|
"/debug/", # Debug endpoints (API access)
|
||||||
"/test/", # Test endpoints (API access)
|
"/test/", # Test endpoints (API access)
|
||||||
"/bulk/", # Bulk operation endpoints (API access)
|
"/bulk/" # Bulk operation endpoints (API access)
|
||||||
"/api/episodes" # Temporary: Make episode endpoints public for testing
|
|
||||||
]
|
]
|
||||||
|
|
||||||
async def dispatch(self, request: Request, call_next):
|
async def dispatch(self, request: Request, call_next):
|
||||||
|
|||||||
@@ -457,6 +457,6 @@
|
|||||||
<!-- Toast Notifications -->
|
<!-- Toast Notifications -->
|
||||||
<div class="toast-container" id="toast-container"></div>
|
<div class="toast-container" id="toast-container"></div>
|
||||||
|
|
||||||
<script src="/static/js/app.js?v=2.8.2-20241025-fix4"></script>
|
<script src="/static/js/app.js?v=2.8.2-20241025-final"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
+30
-37
@@ -11,17 +11,14 @@ from fastapi import FastAPI
|
|||||||
from fastapi.staticfiles import StaticFiles
|
from fastapi.staticfiles import StaticFiles
|
||||||
from fastapi.responses import FileResponse
|
from fastapi.responses import FileResponse
|
||||||
|
|
||||||
# Import existing configuration
|
# Add web interface path for imports
|
||||||
from config.settings import config
|
sys.path.append(os.path.join(os.path.dirname(__file__), "nfoguard-web"))
|
||||||
|
|
||||||
# Import existing database and components
|
# Import web-specific components
|
||||||
from core.database import NFOGuardDatabase
|
from config.web_settings import web_config as config
|
||||||
|
from core.web_database import WebDatabase
|
||||||
# Import web routes from existing system
|
|
||||||
from api.web_routes import register_web_routes
|
from api.web_routes import register_web_routes
|
||||||
|
from api.auth import SimpleAuthMiddleware, create_auth_dependencies
|
||||||
# Import authentication system
|
|
||||||
from api.auth import SimpleAuthMiddleware, AuthSession
|
|
||||||
|
|
||||||
|
|
||||||
def create_web_app() -> FastAPI:
|
def create_web_app() -> FastAPI:
|
||||||
@@ -105,50 +102,46 @@ def main():
|
|||||||
"""Main entry point for NFOGuard Web Interface"""
|
"""Main entry point for NFOGuard Web Interface"""
|
||||||
print("🌐 Starting NFOGuard Web Interface...")
|
print("🌐 Starting NFOGuard Web Interface...")
|
||||||
|
|
||||||
# Use existing config system
|
# Use web config system
|
||||||
web_host = os.environ.get("WEB_HOST", "0.0.0.0")
|
web_host = config.web_host
|
||||||
web_port = int(os.environ.get("WEB_PORT", "8081"))
|
web_port = config.web_port
|
||||||
|
|
||||||
print(f"📊 Configuration: Port {web_port}")
|
print(f"📊 Configuration: Port {web_port}")
|
||||||
|
|
||||||
# Create FastAPI app
|
# Create FastAPI app
|
||||||
app = create_web_app()
|
app = create_web_app()
|
||||||
|
|
||||||
# Initialize database using existing system
|
# Initialize web database (read-only optimized)
|
||||||
try:
|
try:
|
||||||
db = NFOGuardDatabase(config)
|
db = WebDatabase(
|
||||||
|
db_type=config.db_type,
|
||||||
|
host=config.db_host,
|
||||||
|
port=config.db_port,
|
||||||
|
database=config.db_name,
|
||||||
|
user=config.db_user,
|
||||||
|
password=config.db_password
|
||||||
|
)
|
||||||
print(f"✅ Connected to database: {config.db_host}:{config.db_port}/{config.db_name}")
|
print(f"✅ Connected to database: {config.db_host}:{config.db_port}/{config.db_name}")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"❌ Failed to connect to database: {e}")
|
print(f"❌ Failed to connect to database: {e}")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
# Setup authentication if enabled
|
# Create dependencies for dependency injection
|
||||||
auth_enabled = getattr(config, 'web_auth_enabled', False)
|
|
||||||
session_manager = None
|
|
||||||
|
|
||||||
if auth_enabled:
|
|
||||||
session_timeout = getattr(config, 'web_auth_session_timeout', 3600)
|
|
||||||
session_manager = AuthSession(timeout_seconds=session_timeout)
|
|
||||||
print(f"🔐 Web authentication enabled (session timeout: {session_timeout}s)")
|
|
||||||
else:
|
|
||||||
print("🌐 Web authentication disabled")
|
|
||||||
|
|
||||||
# Create dependencies for dependency injection (simplified for web-only)
|
|
||||||
dependencies = {
|
dependencies = {
|
||||||
"db": db,
|
"db": db,
|
||||||
"config": config,
|
"config": config
|
||||||
"nfo_manager": None, # Not needed for read-only web interface
|
|
||||||
"movie_processor": None, # Not needed for read-only web interface
|
|
||||||
"tv_processor": None, # Not needed for read-only web interface
|
|
||||||
"auth_enabled": auth_enabled,
|
|
||||||
"session_manager": session_manager
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Add authentication middleware if enabled (BEFORE routes)
|
# Add authentication dependencies if enabled
|
||||||
if auth_enabled:
|
if config.web_auth_enabled:
|
||||||
# Pass the session manager to middleware so it uses the same instance
|
auth_deps = create_auth_dependencies(config)
|
||||||
app.add_middleware(SimpleAuthMiddleware, config=config, session_manager=session_manager)
|
dependencies.update(auth_deps)
|
||||||
print("🔐 Authentication middleware added to web interface")
|
|
||||||
|
# Add authentication middleware
|
||||||
|
app.add_middleware(SimpleAuthMiddleware, config=config)
|
||||||
|
print(f"🔐 Web authentication enabled for user: {config.web_auth_username}")
|
||||||
|
else:
|
||||||
|
print("🔓 Web authentication disabled - interface is public")
|
||||||
|
|
||||||
# Setup static files and routes
|
# Setup static files and routes
|
||||||
setup_static_files(app)
|
setup_static_files(app)
|
||||||
|
|||||||
Reference in New Issue
Block a user