- CRUD-API /api/connections mit Filter nach Sichtbarkeit und Typ - Sichtbarkeit: privat nur für Besitzer (sonst 404), team für alle bearbeitbar; nur der Besitzer darf team auf privat setzen - Strenge serverseitige Prüfung von Ziel, Port, Benutzer und URL - Dashboard mit Kacheln nach Typ, Filter Alle/Privat/Team, Suche, Dialog zum Anlegen/Bearbeiten, Links itrdp:// und itssh:// - Tests für Validierung und Sichtbarkeitslogik, SETUP.md ergänzt Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
40 lines
1.1 KiB
Python
40 lines
1.1 KiB
Python
"""FastAPI-Einstieg."""
|
|
|
|
from contextlib import asynccontextmanager
|
|
|
|
from fastapi import FastAPI
|
|
from fastapi.staticfiles import StaticFiles
|
|
|
|
from .config import PROJEKT_ROOT
|
|
from .db import init_db
|
|
from .routes import auth_routes, connections
|
|
|
|
|
|
@asynccontextmanager
|
|
async def lifespan(_app: FastAPI):
|
|
init_db()
|
|
yield
|
|
|
|
|
|
app = FastAPI(title="it-connect", lifespan=lifespan, docs_url=None, redoc_url=None)
|
|
|
|
|
|
@app.middleware("http")
|
|
async def sicherheits_header(request, call_next):
|
|
response = await call_next(request)
|
|
response.headers.setdefault("X-Content-Type-Options", "nosniff")
|
|
response.headers.setdefault("X-Frame-Options", "DENY")
|
|
response.headers.setdefault("Referrer-Policy", "no-referrer")
|
|
response.headers.setdefault(
|
|
"Content-Security-Policy",
|
|
"default-src 'self'; frame-ancestors 'none'; base-uri 'none'; form-action 'self'",
|
|
)
|
|
return response
|
|
|
|
|
|
app.include_router(auth_routes.router)
|
|
app.include_router(connections.router)
|
|
|
|
# Frontend zuletzt einhängen, damit /api/* Vorrang hat
|
|
app.mount("/", StaticFiles(directory=PROJEKT_ROOT / "frontend", html=True), name="frontend")
|