-
Notifications
You must be signed in to change notification settings - Fork 2
Description
When a function with run_as_system: true calls another function via context.functions.execute(), the child function does not inherit the system context. It uses its own run_as_system setting from config and evaluates rules against the original calling user.
In MongoDB Realm, system context propagated through context.functions.execute() calls. A child function would automatically run as system if its caller was system, regardless of its own config.
With realm it was possible having a run_as_system function that orchestrates multiple helper functions:
orchestratorFunction(run_as_system: true) callshelperFunctionviacontext.functions.execute()helperFunctionis a shared utility — sometimes called from system context, sometimes directly by users- In Flowerbase,
helperFunctionalways evaluates rules against the user, even when called from a system function - This causes
Insert not permitted/Read not permittederrors for users who shouldn't need direct access
The workaround of adding run_as_system: true to every helper function is not ideal — it removes rule enforcement entirely, even when those helpers are called directly by users who should be subject to access control.
Expected behavior
run_as_system should propagate through context.functions.execute() calls. If the parent runs as system, children should too.