update configuration docker setup for data platform
This commit is contained in:
@@ -12,6 +12,10 @@ import sqladmin
|
||||
|
||||
from app.admin import mount_admin
|
||||
from app.api.v1.routes import router as v1_router
|
||||
from app.routes.pages import router as pages_router
|
||||
from app.routes.auth import router as auth_router
|
||||
from app.routes.admin_users import router as admin_users_router
|
||||
from app.middleware.auth_middleware import WebAuthenticationMiddleware
|
||||
from app.core.config import settings
|
||||
from app.db.init_db import init_db
|
||||
|
||||
@@ -80,8 +84,9 @@ async def global_exception_handler(request, exc):
|
||||
status_code=500,
|
||||
content={"detail": "Internal server error", "error": str(exc)}
|
||||
)
|
||||
# Middleware order is important! They execute in reverse order (LIFO)
|
||||
# WebAuthenticationMiddleware needs SessionMiddleware, so SessionMiddleware must be added AFTER
|
||||
app.add_middleware(ForceHTTPSMiddleware)
|
||||
app.add_middleware(SessionMiddleware, secret_key=settings.ADMIN_SECRET_KEY)
|
||||
app.add_middleware(ForwardedProtoMiddleware)
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
@@ -90,7 +95,17 @@ app.add_middleware(
|
||||
allow_methods=["*"],
|
||||
allow_headers=["*"],
|
||||
)
|
||||
app.include_router(v1_router)
|
||||
# Add web authentication middleware (protects /, /docs, /data-management/* only)
|
||||
# API endpoints (/api/v1/*) continue to use API Key authentication
|
||||
app.add_middleware(WebAuthenticationMiddleware)
|
||||
# SessionMiddleware must be added AFTER middlewares that use it (due to LIFO execution)
|
||||
app.add_middleware(SessionMiddleware, secret_key=settings.ADMIN_SECRET_KEY)
|
||||
|
||||
app.include_router(v1_router) # API endpoints - use API Key auth
|
||||
app.include_router(pages_router) # Web pages - use Keycloak auth
|
||||
app.include_router(auth_router) # Authentication routes
|
||||
app.include_router(admin_users_router) # Admin user management API
|
||||
|
||||
app.mount("/admin/statics", StaticFiles(directory=statics_path), name="admin_statics")
|
||||
app.mount("/apiservice/admin/statics", StaticFiles(directory=statics_path), name="proxy_admin_statics")
|
||||
mount_admin(app)
|
||||
|
||||
Reference in New Issue
Block a user