Make changing engine-run code superuser-only
Writing node source, installing modules and any flow save that adds, retypes or repoints a code node (Function, Command), edits a Command node's settings or changes a node's resources.env now answer 403 for everyone but a superuser. MCP tools and the assistant reach the same routes, so they inherit the gate. Node types report runs_code. The editor shows code read-only with a note, disables a Command node's settings, leaves code nodes and reusable nodes out of the palette and paste, and the Modules page offers no install.
This commit is contained in:
@@ -16,6 +16,7 @@ from fluksio.api.deps import (
|
||||
CurrentUser,
|
||||
FlowControllerDep,
|
||||
WorkerPoolDep,
|
||||
get_code_author,
|
||||
get_current_user,
|
||||
)
|
||||
from fluksio.flow import modules
|
||||
@@ -34,7 +35,9 @@ async def read_modules(controller: FlowControllerDep) -> Any:
|
||||
return await run_in_threadpool(modules.info, controller.store)
|
||||
|
||||
|
||||
@router.post("/apply", response_model=ApplyResult)
|
||||
@router.post(
|
||||
"/apply", response_model=ApplyResult, dependencies=[Depends(get_code_author)]
|
||||
)
|
||||
async def apply_modules(
|
||||
body: ApplyRequest,
|
||||
controller: FlowControllerDep,
|
||||
@@ -43,6 +46,8 @@ async def apply_modules(
|
||||
) -> Any:
|
||||
"""Install exactly these requirements, then hand them to the workers.
|
||||
|
||||
A superuser's: a package runs its own code on install and on import.
|
||||
|
||||
A manifest that does not resolve changes nothing: the venv is left as it
|
||||
was and the stored manifest is only written once the install succeeded.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user