mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-10-03 16:02:12 +00:00
* feat: let a workspace withdraw operator schedule and trigger writes Operators can create, edit and delete schedules and triggers today through the API, CLI and MCP, while the operator_settings flags beside them only hide those pages. An admin who wants operators to see what is scheduled without letting them change it cannot express that. Add manage_schedules and manage_triggers as enforced settings, gated at the schedule handlers and at the generic TriggerCrud routes so every trigger kind is covered by one check. They name capabilities operators already hold, so they are granted unless withdrawn, and absence has to mean "never configured" rather than a value. The read coalesces to true; the update endpoint merges into the stored jsonb with the two fields as Option<bool>, so an omitted key keeps what is stored. operator_settings is git-synced as a whole object, so a settings file written before these keys existed reaches the endpoint on every pull, and a serde or SQL default of either polarity would turn that pull into a silent withdrawal or restoration. The rights are read through a per-process cache, so withdrawing one publishes a notify_event that drops the entry on every replica. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Dsf6VC4MVLisiEoeQkgbr4 * feat: let operators compose flows when the workspace grants the right Adds operator_settings.builder_flows: a workspace setting that lets every operator compose flows out of runnables that already exist. It does not make them authors. The boundary the operator role draws is authoring code and running arbitrary code, and this does not move it: check_flow_is_composition_only walks the value and refuses anything carrying code, including the shapes an obvious walk misses (code hoisted into a flow_node, an AI agent step's tools, and a linked ai_agent resource whose tool list is resolved at run time). What the walk cannot settle it returns for the caller to authorize under RLS: the worker tags the steps pin, every runnable they reference, and the (path, hash) of every version-pinned step. Composing a path is enough to run it and to run it as whoever it runs as, since the worker resolves a step's path with the root DB handle and adopts that runnable's on_behalf_of. A pinned hash needs its own check because dispatch ignores the path beside it. The gate runs on every write and on both request-supplied-value paths, flow preview and flow dependencies, or either becomes the way to run what the write path refuses. Operators of a builder workspace consume a full author seat; the EE companion carries the counting. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Dsf6VC4MVLisiEoeQkgbr4 * feat: enforce operator write rights on the router and in the UI Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * fix: close the capture gap and gate the trigger editors' write actions Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * fix: gate acl writes and the native trigger drawer behind manage rights Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * fix: refuse operator writes with 403 and gate sharing at the drawer Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * perf: resolve identity in the operator write gate only for writes Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * fix: gate the suspended-jobs actions and stop the route check refusing reads Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * fix: explain the empty-state create button when operator writes are withdrawn Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * fix: audit operator settings changes and fold path writes into native rows Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix: open locked editors read-only and group the operator settings Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix: skip email and azure lookups on editor open while triggers are locked Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * docs: state each operator-rights rationale once in comments Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix: address CI review findings on operator write rights Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix: keep capture move gated and skip it in the builders while locked Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix: refuse builder-rights violations with 403 so operators stay logged in Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * refactor: trim duplication in the operator builder gates Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix: hide build app from builder operators on the flow page Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * chore: point at the companion EE PR merged with EE main Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix: keep a builder's drafts list loading past drafts they cannot write Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix: hide saved agents from builder operators in the step picker Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * chore: note the inlined seat rule and drop orphaned sqlx entries Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix: stop a builder's step test from logging them out Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix: refuse a builder's dependency job on a path it cannot write Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix: keep builders from adding dynamic dropdown code to a flow A flow's dropdown code runs as whoever loads its form, so a builder may keep or drop the code stored on the flow it updates, never add or change it. The builder's editor hides the dropdown types and code, and previews options through the deployed flow; the inline dropdown refusal is a 403 so it no longer logs operators out. Also trims rationale comments repeated across sites. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix: show why saving operator settings failed The seat-cap refusal on granting builder rights explains what to do; the toast now carries the server's message instead of a generic failure. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix: check builder flow drafts like deploys and treat dropdown code as code A developer who loads a builder's flow draft in the editor runs its dynamic dropdown code as themselves, so a builder's draft now passes the same checks as a deploy. Dropdown code is refused like step code rather than kept or dropped, which also removes the exact-match comparison that refused builders over whitespace. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix: bill a builder workspace's operators as developers on cloud The cloud seat count behind the Premium page, the sidebar usage and the fork cap still weighed every operator at half a seat, while the builder right makes them authors. The out-of-repo invoicing job must follow the same rule. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix: check a builder's flow draft as it will be stored Draft storage strips NUL escapes after the builder check, so a key ending in one (value\u0000, x-windmill-dyn-select-code\u0000) passed the check as an unknown field and was stored under its plain name. The check now reads the sanitized text. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix: list a builder's flow drafts and hide hub imports from builders A builder's undeployed flows now appear in the home list, the flow list and the folder counts. Hub project imports and templates bring scripts and apps along, so builders are no longer offered them. The docs record builders' JavaScript expressions as an accepted risk. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix: keep the stored builder right when a settings payload omits it A git-synced settings file written before the key existed withdrew the right on every push. builder_flows now follows the manage_* rights: an omitted key leaves the stored value, and the CLI does not count it as a difference. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix: word builder refusals by what the flow contains, test the tag refusal A builder refused on a developer's flow never changed its code, so the refusals now describe the flow ("has inline code, so only a developer can edit this flow") rather than an authoring attempt. The grant confirmation uses the neutral dialog: granting changes billing but destroys nothing. The integration test pins the refusal of a worker tag the workspace cannot use. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix: read builder rights from the operating workspace, gate the flow page's audit logs entry Builder rights now come from useOperatorBuilderFlows(), next to the schedule and trigger locks, so an editor embedded for another workspace answers about that workspace; the legacy AI chat, one instance for the whole app, reads the navigation workspace. The flow page's Audit logs entry follows the operator audit_logs setting now that builders open that menu. Operator settings reset every value on load, null settings included, so nothing carries over from the previous workspace. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix: pick a dynamic dropdown's code source by the operating user's role The flow input editor, the flow test panel and the flow chat send the dropdown request to the operating workspace, so they now also choose inline versus deployed code by the role held there, through useOperatingUser(), instead of the navigation workspace's. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * chore: update ee-repo-ref to 40ac1c5f8cbce3843b582d9b392d3f3cc7eca3e6 This commit updates the EE repository reference after PR #815 was merged in windmill-ee-private. Previous ee-repo-ref: 31c9e66884b8ca805b20bbfad41fc428fbedbc0e New ee-repo-ref: 40ac1c5f8cbce3843b582d9b392d3f3cc7eca3e6 Automated by sync-ee-ref workflow. --------- Co-authored-by: Claude Opus 5 <noreply@anthropic.com> Co-authored-by: windmill-internal-app[bot] <windmill-internal-app[bot]@users.noreply.github.com>
97 lines
6.4 KiB
Markdown
97 lines
6.4 KiB
Markdown
# Operator write rights
|
|
|
|
Most of `workspace_settings.operator_settings` is visibility: flags that hide pages from operators
|
|
so the UI stays uncluttered. They are not enforced, and were never meant to be.
|
|
|
|
`manage_schedules` and `manage_triggers` are different. They are **enforced** on the write paths,
|
|
because hiding the schedules page never stopped an operator creating a schedule through the API,
|
|
the CLI or MCP. An admin who wants operators to see what is scheduled without letting them change
|
|
it could not express that with a visibility flag alone.
|
|
|
|
## Where the gate lives
|
|
|
|
On the router, not in the handlers. `gate_operator_writes` is layered in `windmill-api/src/lib.rs`
|
|
over the schedules router, the trigger routers, the native-trigger routers and capture, and refuses
|
|
anything that is not a GET/HEAD/OPTIONS.
|
|
|
|
That is not a style choice. A trigger kind can register routes of its own beside the shared CRUD
|
|
ones — bulk HTTP creation, the Postgres publication and replication-slot setup — and those are
|
|
hand-written, one per feature. A check inside each handler misses every one of those extra routes,
|
|
along with the whole native-trigger family, which does not use the shared handlers at all. On the
|
|
router the author of the next route writes nothing and is covered anyway.
|
|
|
|
**A layer only covers the routers it is on.** It closes routes added *inside* a gated router; it
|
|
says nothing about a new feature that performs trigger writes from a router of its own. Capture is
|
|
exactly that — it configures a trigger without creating one, and saving a Postgres capture config
|
|
creates a replication slot and a publication on the target database — and it needed its own layer
|
|
rather than inheriting one. That includes `move`, which re-points existing capture configs between
|
|
runnables: the builders, which call it on every script and flow creation, skip it while the right is
|
|
withdrawn, since captures only arrive through a saved config. Before adding a feature that writes
|
|
trigger or schedule state, ask which router it lands on.
|
|
|
|
Three consequences to keep in mind when adding a route under one of these:
|
|
|
|
- A read served over POST gets refused, and an unprompted refusal reaches the operator as a bare
|
|
privilege toast. The connection test is button-fired, so it only refuses someone who asked. The
|
|
HTTP route and email address availability checks and the Azure scope and topic lists run on
|
|
editor open, so their config sections skip them while the lock is set. Put new reads on GET; if
|
|
one must stay POST, check nothing fires it unprompted.
|
|
- Anything mounted under a gated router inherits the gate. The native-trigger mount also carries
|
|
the workspace's integration setup, which is a settings concern, so the layer goes on the trigger
|
|
routes alone rather than the whole mount.
|
|
- A route operating on *jobs* rather than configuration inherits it too.
|
|
`resume_suspended_trigger_jobs` and its cancel twin stay gated: an operator who can neither
|
|
suspend nor un-suspend a trigger should not override the consequence. Weigh the next one rather
|
|
than taking the router's answer.
|
|
|
|
`check_operator_can_manage` is still the function underneath, for a write that cannot be reached
|
|
through one of these routers. `/acls/add` and `/acls/remove` are the case that needs it: sharing an
|
|
object is a write to it, but that router serves every kind there is, so it can only be gated per
|
|
kind from inside the handlers. `manage_kind_for_acl_kind` holds that list, spelled out rather than
|
|
matched on the `_trigger` suffix so a kind named otherwise cannot slip through ungated.
|
|
|
|
It refuses with `PermissionDenied` (403), never `NotAuthorized` (401): the frontend reads an
|
|
uncaught 401 as an expired session and logs the user out, so 401 here ejects an operator from the
|
|
app rather than telling them why. Both integration tests assert the status for that reason.
|
|
|
|
## In the UI
|
|
|
|
The shared lists (`TriggerList`, `SchedulesList`, `NativeTriggerTable`) derive a per-row `canEdit`
|
|
from `canWrite && !$lock` and leave `canWrite` itself alone, because `canWrite` also tells
|
|
`SharedBadge` whether a row belongs to someone else — fold the lock into it and every row,
|
|
including ones the operator owns and has never shared, claims to be shared read-only. Gate write
|
|
affordances on `canEdit`, never the badge.
|
|
|
|
Each schedule and trigger editor folds the lock into its own `can_write`, so a withdrawn operator
|
|
gets the same read-only editor as someone without write access to the folder. There, unlike the
|
|
list pages, nothing reads `can_write` as a sharing hint. It is derived for a new trigger too, so the
|
|
toolbar, which takes its permissions from `can_write`, needs no lock of its own. Sharing is gated in
|
|
`ShareModal`, which locks itself off the kind it was opened on rather than relying on each of the
|
|
dozen menu entries that open it.
|
|
|
|
The cache is per process, so withdrawing a right has to reach every replica: an `AFTER UPDATE OF
|
|
operator_settings` trigger writes a `notify_operator_settings_change` row and `process_notify_event`
|
|
drops the entry. Keep both ends if you touch either, or a workspace that withdrew a right keeps
|
|
authorizing writes on every other replica until its own entry expires.
|
|
|
|
## Granted unless withdrawn
|
|
|
|
These name capabilities operators already hold, so absence has to mean "never configured", not a
|
|
value. That is easy to get wrong in two places, and the obvious implementation gets both wrong:
|
|
|
|
- The read coalesces to **true** (`operator_rights`), including for a workspace with no
|
|
`workspace_settings` row, which is what `OperatorManageRights::default` is for. Coalescing to
|
|
false instead revokes the right on upgrade for every workspace that ever saved operator settings,
|
|
since those rows carry explicit keys and none of them is this one.
|
|
- The update endpoint **merges** into the stored jsonb and takes these two as `Option<bool>`, so an
|
|
omitted key keeps its stored value. It has to: `operator_settings` is git-synced as a whole
|
|
object (`cli/src/core/settings.ts` posts the file's contents verbatim), so a settings file
|
|
written before these keys existed reaches the endpoint on every pull. A serde or SQL default of
|
|
either polarity turns that pull into a silent withdrawal or a silent restoration.
|
|
|
|
The visibility flags are plain `bool` and always serialize, so the merge is a no-op for them and
|
|
their behaviour is unchanged.
|
|
|
|
Do not model a right that an admin *grants* on these. Granted-by-default and granted-on-request
|
|
are opposite polarities, and a gate written for one is wrong for the other.
|