mirror of
https://github.com/Av0idD4rk/firegex.git
synced 2026-10-23 14:31:00 +00:00
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.
23 lines
861 B
Python
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)
|