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:
@@ -444,3 +444,19 @@ def get_current_active_superuser(current_user: CurrentUser) -> User:
|
||||
status_code=403, detail="The user doesn't have enough privileges"
|
||||
)
|
||||
return current_user
|
||||
|
||||
|
||||
#: Why a non-superuser is refused a change to what the engine executes.
|
||||
CODE_IS_SUPERUSERS = "Only a superuser can change code the engine runs"
|
||||
|
||||
|
||||
def get_code_author(current_user: CurrentUser) -> User:
|
||||
"""A superuser, the only account that may change code the engine runs.
|
||||
|
||||
Node code, a command, an installed package: each runs as the engine, with
|
||||
its signing key and every secret in reach, so whoever writes one holds
|
||||
the instance whatever their account says.
|
||||
"""
|
||||
if not current_user.is_superuser:
|
||||
raise HTTPException(status_code=403, detail=CODE_IS_SUPERUSERS)
|
||||
return current_user
|
||||
|
||||
Reference in New Issue
Block a user