Saltar a contenido

app.main

app = FastAPI(title='Framework de Pruebas SQL', description='API para ejecución, validación y trazabilidad de pruebas en bases de datos relacionales (Oracle MVP).', version='2.0.0') module-attribute

cors_origins_raw = os.getenv('CORS_ORIGINS', 'http://localhost,http://localhost:3000,http://127.0.0.1,http://127.0.0.1:3000') module-attribute

origins = [o.strip() for o in cors_origins_raw.split(',') if o.strip()] module-attribute

allow_creds = '*' not in origins module-attribute

log_http = obtener_log('http') module-attribute

RUTAS_PUBLICAS = {'/', '/health', '/login', '/api/login', '/api/logout', '/api/register'} module-attribute

CABECERAS_SEGURIDAD = {'X-Content-Type-Options': 'nosniff', 'X-Frame-Options': 'DENY', 'Referrer-Policy': 'same-origin', 'Permissions-Policy': 'camera=(), microphone=(), geolocation=()'} module-attribute

con_sesion = [Depends(usuario_actual)] module-attribute

frontend_path = os.path.join(os.path.dirname(__file__), '..', 'frontend') module-attribute

cookie_auth_middleware(request, call_next) async

Primera barrera: sin una cookie de sesión firmada y vigente, /api/* responde 401 y las páginas redirigen a /login. La segunda barrera (cuenta activa, sesión no anulada y rol) la aplica la dependencia usuario_actual en cada router.

get_login_page()

health_check()

read_root()