firegex/backend/application/coordinator.py
av0idd4rk 863422f202 Add authenticated MCP server and agent guide
Expose 28 tools with shared REST operations, role-scoped bearer authentication, revisions, durable retries, snapshots, jobs and timed rollback. Add Docker verification harnesses and setup/workflow documentation in docs/mcp.md and inst.md. Validated with 330 unit tests, two consecutive 25-case MCP/import runs, and restart recovery; the full upstream regression run remains incomplete.
2026-10-23 09:46:44 +03:00

23 lines
861 B
Python

"""Serialize configuration access across REST, MCP and recovery jobs."""
import asyncio
command_lock = asyncio.Lock()
class ConfigurationMiddleware:
def __init__(self, app):
self.app = app
async def __call__(self, scope, receive, send):
path = scope.get("path", "")
# Status/login remain responsive while a datapath is being prepared. Socket.IO
# is also independent: it must be able to deliver invalidations during a write.
guarded = path.startswith(("/api/services", "/api/firewall")) or path in {
"/api/import", "/api/export", "/api/reset", "/api/change-password", "/api/auth-mode",
}
if scope["type"] == "http" and guarded:
async with command_lock:
await self.app(scope, receive, send)
else:
await self.app(scope, receive, send)