Skip to content

run_as_system should propagate to child functions via context.functions.execute() #39

@mikarollenmillernovacode

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) calls helperFunction via context.functions.execute()
  • helperFunction is a shared utility — sometimes called from system context, sometimes directly by users
  • In Flowerbase, helperFunction always evaluates rules against the user, even when called from a system function
  • This causes Insert not permitted / Read not permitted errors 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions