- MSAL.js (PKCE) browser-side auth against Azure Entra ID - Bearer token interceptor on all API calls - Backend JWT validation middleware (python-jose + JWKS) - All API routes protected; /api/health stays public - vite base set to /gsb/, BrowserRouter basename=/gsb - docker-compose: remove frontend service, lock backend to 127.0.0.1:8002, remove dev volumes - backend: 2 workers, no --reload Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
57 lines
1.8 KiB
Python
57 lines
1.8 KiB
Python
import logging
|
|
|
|
from fastapi import FastAPI, Depends
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
|
|
# Enable app-level logging
|
|
logging.basicConfig(level=logging.INFO, format="%(levelname)s [%(name)s] %(message)s")
|
|
|
|
from app.api import gmal, ingest, projects, matching, ratecard
|
|
from app.middleware.auth import get_current_user
|
|
|
|
app = FastAPI(title="Scope Builder", version="1.0.0")
|
|
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=[
|
|
"http://localhost:3000",
|
|
"http://localhost:3001",
|
|
"http://localhost:3010",
|
|
"https://optical-dev.oliver.solutions",
|
|
],
|
|
allow_credentials=True,
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
|
|
_auth = Depends(get_current_user)
|
|
|
|
app.include_router(gmal.router, prefix="/api/gmal", tags=["GMAL"], dependencies=[_auth])
|
|
app.include_router(ingest.router, prefix="/api/gmal", tags=["Ingest"], dependencies=[_auth])
|
|
app.include_router(projects.router, prefix="/api/projects", tags=["Projects"], dependencies=[_auth])
|
|
app.include_router(matching.router, prefix="/api/projects", tags=["Matching"], dependencies=[_auth])
|
|
app.include_router(ratecard.router, prefix="/api/projects", tags=["Ratecard"], dependencies=[_auth])
|
|
|
|
|
|
@app.get("/api/health")
|
|
async def health():
|
|
return {"status": "ok"}
|
|
|
|
|
|
@app.get("/api/ai/usage", dependencies=[_auth])
|
|
async def ai_usage():
|
|
from app.utils.claude_client import get_usage_stats
|
|
return get_usage_stats()
|
|
|
|
|
|
@app.post("/api/ai/usage/reset", dependencies=[_auth])
|
|
async def ai_usage_reset():
|
|
from app.utils.claude_client import reset_usage_stats
|
|
reset_usage_stats()
|
|
return {"detail": "Usage stats reset"}
|
|
|
|
|
|
@app.get("/api/ai/debug", dependencies=[_auth])
|
|
async def ai_debug():
|
|
from app.utils.claude_client import get_debug_log
|
|
return get_debug_log()
|