mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-12-03 08:10:27 +00:00
refactor: store a view-only grant as "read" in extra_perms instead of a view_only column
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
16ad7ce9f1
commit
c598383f27
@@ -46,8 +46,8 @@ Open-source platform for internal tools, workflows, API integrations, background
|
||||
- **Enterprise**: `docs/enterprise.md` — EE file conventions and PR workflow
|
||||
- **Workspace roles**: `docs/workspace-roles.md` — instance-defined roles with per-workspace
|
||||
overrides, the capabilities a role holds, why `ApiAuthed::is_operator` must be derived from the
|
||||
role, the `role_seat` table billing reads, and the view-only grants on folders and items, which
|
||||
every copy of a script, flow, agent or folder row must carry
|
||||
role, the `role_seat` table billing reads, and the levels an `extra_perms` value can hold
|
||||
(`true`/`false` or `"read"`/`"run"`/`"write"`), which every reader must accept
|
||||
- **Operator write rights**: `docs/operator-write-rights.md` — which `operator_settings` flags are
|
||||
enforced rather than cosmetic, and why a right that is granted-unless-withdrawn needs `Option`
|
||||
fields and a jsonb merge rather than a serde default
|
||||
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "\n INSERT INTO script\n (workspace_id, hash, path, parent_hashes, summary, description, content, created_by, schema, is_template, extra_perms, lock, language, kind, tag, envs, concurrent_limit, concurrency_time_window_s, cache_ttl, cache_ignore_s3_path, dedicated_worker, ws_error_handler_muted, priority, restart_unless_cancelled, delete_after_use, delete_after_secs, timeout, concurrency_key, visible_to_runner_only, auto_kind, codebase, has_preprocessor, on_behalf_of, on_behalf_of_email, schema_validation, assets, debounce_key, debounce_delay_s, runnable_settings_handle, modules, labels, job_token_scopes, lock_error_logs, created_at)\n\n SELECT workspace_id, $1, path, array_prepend($2::bigint, COALESCE(parent_hashes, '{}'::bigint[])), summary, description, content, created_by, schema, is_template, extra_perms, $4::text, language, kind, tag, envs, concurrent_limit, concurrency_time_window_s, cache_ttl, cache_ignore_s3_path, dedicated_worker, ws_error_handler_muted, priority, restart_unless_cancelled, delete_after_use, delete_after_secs, timeout, concurrency_key, visible_to_runner_only, auto_kind, codebase, has_preprocessor, on_behalf_of, on_behalf_of_email, schema_validation, assets, debounce_key, debounce_delay_s, runnable_settings_handle, COALESCE($5::jsonb, modules), labels, job_token_scopes, $6::text, clock_timestamp()\n\n FROM script WHERE hash = $2 AND workspace_id = $3;\n ",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Int8",
|
||||
"Int8",
|
||||
"Text",
|
||||
"Text",
|
||||
"Jsonb",
|
||||
"Text"
|
||||
]
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "05b610ad1809d487c32e85b0392cfca8913ba1129fdf4978a8a4738689786160"
|
||||
}
|
||||
-16
@@ -1,16 +0,0 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "INSERT INTO resource (workspace_id, path, value, description, resource_type, extra_perms, view_only, edited_at, created_by)\n SELECT $2, path,\n CASE WHEN $3::text IS NOT NULL AND resource_type = 'ai_agent'\n AND jsonb_typeof(value) = 'object' AND value ? 'on_behalf_of'\n THEN jsonb_set(value, '{on_behalf_of}', to_jsonb($3::text))\n ELSE value END,\n description, resource_type, extra_perms, view_only, edited_at, created_by\n FROM resource\n WHERE workspace_id = $1",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Text",
|
||||
"Varchar",
|
||||
"Text"
|
||||
]
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "0c2eb37f3c10de954af0196596e4c286a2508d5fc8303356b74502a230a46e26"
|
||||
}
|
||||
-19
@@ -1,19 +0,0 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "\n INSERT INTO script\n (workspace_id, hash, path, parent_hashes, summary, description, content, created_by, schema, is_template, extra_perms, view_only, lock, language, kind, tag, envs, concurrent_limit, concurrency_time_window_s, cache_ttl, cache_ignore_s3_path, dedicated_worker, ws_error_handler_muted, priority, restart_unless_cancelled, delete_after_use, delete_after_secs, timeout, concurrency_key, visible_to_runner_only, auto_kind, codebase, has_preprocessor, on_behalf_of, on_behalf_of_email, schema_validation, assets, debounce_key, debounce_delay_s, runnable_settings_handle, modules, labels, job_token_scopes, lock_error_logs, created_at)\n\n SELECT workspace_id, $1, path, array_prepend($2::bigint, COALESCE(parent_hashes, '{}'::bigint[])), summary, description, content, created_by, schema, is_template, extra_perms, view_only, $4::text, language, kind, tag, envs, concurrent_limit, concurrency_time_window_s, cache_ttl, cache_ignore_s3_path, dedicated_worker, ws_error_handler_muted, priority, restart_unless_cancelled, delete_after_use, delete_after_secs, timeout, concurrency_key, visible_to_runner_only, auto_kind, codebase, has_preprocessor, on_behalf_of, on_behalf_of_email, schema_validation, assets, debounce_key, debounce_delay_s, runnable_settings_handle, COALESCE($5::jsonb, modules), labels, job_token_scopes, $6::text, clock_timestamp()\n\n FROM script WHERE hash = $2 AND workspace_id = $3;\n ",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Int8",
|
||||
"Int8",
|
||||
"Text",
|
||||
"Text",
|
||||
"Jsonb",
|
||||
"Text"
|
||||
]
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "10d82ac4c6c42512110d44bb41f74be5dc49bd2765ac3a81961c9eaaa477e3a4"
|
||||
}
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "UPDATE resource SET extra_perms = extra_perms - ('u/' || $2) || jsonb_build_object(('u/' || $1), extra_perms->('u/' || $2)), view_only = array_replace(view_only, 'u/' || $2, 'u/' || $1) WHERE extra_perms ? ('u/' || $2) AND workspace_id = $3",
|
||||
"query": "UPDATE resource SET extra_perms = extra_perms - ('u/' || $2) || jsonb_build_object(('u/' || $1), extra_perms->('u/' || $2)) WHERE extra_perms ? ('u/' || $2) AND workspace_id = $3",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
@@ -12,5 +12,5 @@
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "696c2f4c76c3876c4ff65ebacfd2aae6d9c8ccdcc0e621ac5ca2bf28a30fe2e4"
|
||||
"hash": "1f003a8a6a9402f5f7021b032281a9aa70a8f89777e95e0415877ffa90ecd87c"
|
||||
}
|
||||
-26
@@ -1,26 +0,0 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "WITH item AS (\n -- The newest version only: a script reusing a retired path starts with no grants,\n -- and the retired versions' must not run it.\n (SELECT extra_perms, view_only FROM script\n WHERE $5 = 'script' AND workspace_id = $1 AND path = $2\n ORDER BY created_at DESC LIMIT 1)\n UNION ALL SELECT extra_perms, view_only FROM flow\n WHERE $5 = 'flow' AND workspace_id = $1 AND path = $2\n UNION ALL SELECT extra_perms, view_only FROM resource\n WHERE $5 = 'resource' AND workspace_id = $1 AND path = $2\n )\n SELECT EXISTS (\n SELECT 1 FROM item WHERE acl_grants_run(item.extra_perms, item.view_only, $4)\n ) OR EXISTS (\n SELECT 1 FROM folder f\n WHERE f.workspace_id = $1 AND f.name = $3\n AND (f.owners::text[] && $4 OR acl_grants_run(f.extra_perms, f.view_only, $4))\n ) AS \"can_run!\"",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "can_run!",
|
||||
"type_info": "Bool"
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Text",
|
||||
"Text",
|
||||
"Text",
|
||||
"TextArray",
|
||||
"Text"
|
||||
]
|
||||
},
|
||||
"nullable": [
|
||||
null
|
||||
]
|
||||
},
|
||||
"hash": "2823efb1bd4f76d2887a08e6f53cfbdf9f4c3037766c287c6a2eaa9a03b4fab9"
|
||||
}
|
||||
-15
@@ -1,15 +0,0 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "UPDATE folder SET view_only = ARRAY(\n SELECT v FROM unnest(view_only) v WHERE extra_perms->>v = 'false'\n ) WHERE name = $1 AND workspace_id = $2",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Text",
|
||||
"Text"
|
||||
]
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "410ca1d957cbd4f10c6c215f911416534453510861774c9529c2624f7c271c33"
|
||||
}
|
||||
-15
@@ -1,15 +0,0 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "INSERT INTO flow (\n workspace_id, path, summary, description, value, edited_by, edited_at,\n archived, schema, extra_perms, view_only, dependency_job, tag,\n ws_error_handler_muted, dedicated_worker, timeout, visible_to_runner_only,\n concurrency_key, versions, on_behalf_of, on_behalf_of_email, lock_error_logs,\n job_token_scopes\n )\n SELECT $2, path, summary, description, value, edited_by, edited_at,\n archived, schema, extra_perms, view_only, NULL, tag,\n ws_error_handler_muted, dedicated_worker, timeout, visible_to_runner_only,\n concurrency_key, ARRAY[]::bigint[],\n -- Same predicate as clone_scripts.\n CASE WHEN on_behalf_of LIKE 'u/%' THEN\n (SELECT on_behalf_of WHERE EXISTS (\n SELECT 1 FROM usr u WHERE u.workspace_id = $2::varchar\n AND u.username = substring(on_behalf_of from 3)\n UNION ALL\n SELECT 1 FROM password p WHERE p.super_admin\n AND (p.username = substring(on_behalf_of from 3)\n OR p.email = substring(on_behalf_of from 3))))\n WHEN on_behalf_of LIKE 'g/%' THEN\n (SELECT on_behalf_of WHERE EXISTS (\n SELECT 1 FROM group_ g WHERE g.workspace_id = $2::varchar\n AND g.name = substring(on_behalf_of from 3)))\n ELSE\n (SELECT on_behalf_of WHERE EXISTS (\n SELECT 1 FROM usr u WHERE u.workspace_id = $2::varchar\n AND u.username = on_behalf_of\n UNION ALL\n SELECT 1 FROM password p WHERE p.email = on_behalf_of\n AND p.super_admin))\n END, on_behalf_of_email, lock_error_logs, job_token_scopes\n FROM flow\n WHERE workspace_id = $1",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Text",
|
||||
"Varchar"
|
||||
]
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "412524514458af602f4319887d04e2da64a443e7699b8d8579a5795d69dde38b"
|
||||
}
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "SELECT name FROM folder\n WHERE workspace_id = $2 AND extra_perms ?| $1 AND cardinality(view_only) > 0\n AND NOT owners::text[] && $1 AND NOT acl_grants_run(extra_perms, view_only, $1)",
|
||||
"query": "SELECT name FROM folder\n WHERE workspace_id = $2 AND extra_perms ?| $1\n AND NOT owners::text[] && $1 AND NOT acl_grants_run(extra_perms, $1)",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
@@ -19,5 +19,5 @@
|
||||
false
|
||||
]
|
||||
},
|
||||
"hash": "0766c40a729c2ba448f838b4492d6e2cad53d4ad27041beab87f0bf5fab92a16"
|
||||
"hash": "41a17f941cf4d97ebbca23a0a206a8dad940c6c19baa2ca4481ed69bb481c83f"
|
||||
}
|
||||
+6
-12
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "SELECT workspace_id, name, display_name, owners, extra_perms, view_only, summary, created_by, edited_at, default_permissioned_as, labels FROM folder WHERE name = $1 AND workspace_id = $2",
|
||||
"query": "SELECT workspace_id, name, display_name, owners, extra_perms, summary, created_by, edited_at, default_permissioned_as, labels FROM folder WHERE name = $1 AND workspace_id = $2",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
@@ -30,31 +30,26 @@
|
||||
},
|
||||
{
|
||||
"ordinal": 5,
|
||||
"name": "view_only",
|
||||
"type_info": "TextArray"
|
||||
},
|
||||
{
|
||||
"ordinal": 6,
|
||||
"name": "summary",
|
||||
"type_info": "Text"
|
||||
},
|
||||
{
|
||||
"ordinal": 7,
|
||||
"ordinal": 6,
|
||||
"name": "created_by",
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"ordinal": 8,
|
||||
"ordinal": 7,
|
||||
"name": "edited_at",
|
||||
"type_info": "Timestamptz"
|
||||
},
|
||||
{
|
||||
"ordinal": 9,
|
||||
"ordinal": 8,
|
||||
"name": "default_permissioned_as",
|
||||
"type_info": "Jsonb"
|
||||
},
|
||||
{
|
||||
"ordinal": 10,
|
||||
"ordinal": 9,
|
||||
"name": "labels",
|
||||
"type_info": "TextArray"
|
||||
}
|
||||
@@ -71,7 +66,6 @@
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
@@ -79,5 +73,5 @@
|
||||
true
|
||||
]
|
||||
},
|
||||
"hash": "4f2c9e6206391e9b7dbcbd0bffeeef5fb70f6cdf445c114f8f2925ba39551be7"
|
||||
"hash": "42600bdeb6b86ac306ab276cb49241508776f5f998821e04bc92df917176cea6"
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "INSERT INTO folder (workspace_id, name, display_name, owners, extra_perms, summary, edited_at, created_by, default_permissioned_as, labels)\n SELECT $2, name, display_name, owners, extra_perms, summary, edited_at, created_by, default_permissioned_as, labels\n FROM folder\n WHERE workspace_id = $1",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Text",
|
||||
"Varchar"
|
||||
]
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "4ca364e493dd51d5f83489dc4674eeadcf092b37a20d03d52f2160ca21f79fb0"
|
||||
}
|
||||
-15
@@ -1,15 +0,0 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "INSERT INTO folder (workspace_id, name, display_name, owners, extra_perms, view_only, summary, edited_at, created_by, default_permissioned_as, labels)\n SELECT $2, name, display_name, owners, extra_perms, view_only, summary, edited_at, created_by, default_permissioned_as, labels\n FROM folder\n WHERE workspace_id = $1",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Text",
|
||||
"Varchar"
|
||||
]
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "50c7797e3214841ba005618e170c7150c7292a4510ba5c751e40f7c5e2fc5841"
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "INSERT INTO flow\n (workspace_id, path, summary, description, archived, extra_perms, dependency_job, tag, ws_error_handler_muted, dedicated_worker, timeout, visible_to_runner_only, on_behalf_of, on_behalf_of_email, concurrency_key, versions, value, schema, edited_by, edited_at, labels, job_token_scopes)\n SELECT workspace_id, $1, summary, description, archived, extra_perms, dependency_job, tag, ws_error_handler_muted, dedicated_worker, timeout, visible_to_runner_only, on_behalf_of, on_behalf_of_email, concurrency_key, versions, value, schema, edited_by, edited_at, labels, job_token_scopes\n FROM flow\n WHERE path = $2 AND workspace_id = $3",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Varchar",
|
||||
"Text",
|
||||
"Text"
|
||||
]
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "580271c5fe178f5e31f3e211cd7fea97aec4d6d3ec65d3e7402811c7dddbbf64"
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "INSERT INTO folder (name, workspace_id, display_name, owners, extra_perms, summary, edited_at, created_by, default_permissioned_as, labels) SELECT name, $1, display_name, owners, extra_perms, summary, edited_at, created_by, default_permissioned_as, labels FROM folder WHERE workspace_id = $2",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Varchar",
|
||||
"Text"
|
||||
]
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "5b4214deb7677ae16df0bea7c6553461dee4bcc8d7180a9a517d5809c42e11d7"
|
||||
}
|
||||
-16
@@ -1,16 +0,0 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "UPDATE script SET view_only = $1 WHERE hash = $2 AND workspace_id = $3",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"TextArray",
|
||||
"Int8",
|
||||
"Text"
|
||||
]
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "5d7c49c74b6324215f89b0a3f1587374b4ff0fd03c4c48bf16d876df3978bdfa"
|
||||
}
|
||||
+6
-12
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "SELECT workspace_id, name, display_name, owners, extra_perms, view_only, summary, created_by, edited_at, default_permissioned_as, labels FROM folder WHERE workspace_id = $1 ORDER BY name asc LIMIT $2 OFFSET $3",
|
||||
"query": "SELECT workspace_id, name, display_name, owners, extra_perms, summary, created_by, edited_at, default_permissioned_as, labels FROM folder WHERE workspace_id = $1 ORDER BY name asc LIMIT $2 OFFSET $3",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
@@ -30,31 +30,26 @@
|
||||
},
|
||||
{
|
||||
"ordinal": 5,
|
||||
"name": "view_only",
|
||||
"type_info": "TextArray"
|
||||
},
|
||||
{
|
||||
"ordinal": 6,
|
||||
"name": "summary",
|
||||
"type_info": "Text"
|
||||
},
|
||||
{
|
||||
"ordinal": 7,
|
||||
"ordinal": 6,
|
||||
"name": "created_by",
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"ordinal": 8,
|
||||
"ordinal": 7,
|
||||
"name": "edited_at",
|
||||
"type_info": "Timestamptz"
|
||||
},
|
||||
{
|
||||
"ordinal": 9,
|
||||
"ordinal": 8,
|
||||
"name": "default_permissioned_as",
|
||||
"type_info": "Jsonb"
|
||||
},
|
||||
{
|
||||
"ordinal": 10,
|
||||
"ordinal": 9,
|
||||
"name": "labels",
|
||||
"type_info": "TextArray"
|
||||
}
|
||||
@@ -72,7 +67,6 @@
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
@@ -80,5 +74,5 @@
|
||||
true
|
||||
]
|
||||
},
|
||||
"hash": "95a6b9f7c302ca86f10a9ee0b51b10ec320663d2038928c90a8199335c53d482"
|
||||
"hash": "636dd6906a20b608eea34e04a81bddb79398f57a34d180d08aa00aaaaa1050c8"
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "WITH item AS (\n -- The newest version only: a script reusing a retired path starts with no grants,\n -- and the retired versions' must not run it.\n (SELECT extra_perms FROM script\n WHERE $5 = 'script' AND workspace_id = $1 AND path = $2\n ORDER BY created_at DESC LIMIT 1)\n UNION ALL SELECT extra_perms FROM flow\n WHERE $5 = 'flow' AND workspace_id = $1 AND path = $2\n UNION ALL SELECT extra_perms FROM resource\n WHERE $5 = 'resource' AND workspace_id = $1 AND path = $2\n )\n SELECT EXISTS (\n SELECT 1 FROM item WHERE acl_grants_run(item.extra_perms, $4)\n ) OR EXISTS (\n SELECT 1 FROM folder f\n WHERE f.workspace_id = $1 AND f.name = $3\n AND (f.owners::text[] && $4 OR acl_grants_run(f.extra_perms, $4))\n ) AS \"can_run!\"",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "can_run!",
|
||||
"type_info": "Bool"
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Text",
|
||||
"Text",
|
||||
"Text",
|
||||
"TextArray",
|
||||
"Text"
|
||||
]
|
||||
},
|
||||
"nullable": [
|
||||
null
|
||||
]
|
||||
},
|
||||
"hash": "6bb977fdca71a6a98a651b986ad5650c53b43416ea5913d1755bc5214b8c715f"
|
||||
}
|
||||
+15
-21
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "SELECT resource.workspace_id, resource.path, resource.value, resource.description,\n resource.resource_type, resource.extra_perms, resource.view_only, resource.created_by, resource.edited_at,\n resource.labels,\n folder_labels(resource.workspace_id, resource.path) as \"inherited_labels?\",\n (now() > account.expires_at) as is_expired, account.refresh_token != '' as is_refreshed,\n account.refresh_error, account.scopes as \"scopes?\",\n variable.path IS NOT NULL as is_linked,\n variable.is_oauth as \"is_oauth?\",\n variable.account,\n ws_specific.path IS NOT NULL as ws_specific,\n null::bool as draft_only,\n null::bool as is_draft\n FROM resource\n LEFT JOIN variable ON variable.path = resource.path AND variable.workspace_id = $2\n LEFT JOIN account ON variable.account = account.id AND account.workspace_id = $2\n LEFT JOIN ws_specific ON ws_specific.path = resource.path AND ws_specific.workspace_id = $2 AND ws_specific.item_kind = 'resource'\n WHERE resource.path = $1 AND resource.workspace_id = $2",
|
||||
"query": "SELECT resource.workspace_id, resource.path, resource.value, resource.description,\n resource.resource_type, resource.extra_perms, resource.created_by, resource.edited_at,\n resource.labels,\n folder_labels(resource.workspace_id, resource.path) as \"inherited_labels?\",\n (now() > account.expires_at) as is_expired, account.refresh_token != '' as is_refreshed,\n account.refresh_error, account.scopes as \"scopes?\",\n variable.path IS NOT NULL as is_linked,\n variable.is_oauth as \"is_oauth?\",\n variable.account,\n ws_specific.path IS NOT NULL as ws_specific,\n null::bool as draft_only,\n null::bool as is_draft\n FROM resource\n LEFT JOIN variable ON variable.path = resource.path AND variable.workspace_id = $2\n LEFT JOIN account ON variable.account = account.id AND account.workspace_id = $2\n LEFT JOIN ws_specific ON ws_specific.path = resource.path AND ws_specific.workspace_id = $2 AND ws_specific.item_kind = 'resource'\n WHERE resource.path = $1 AND resource.workspace_id = $2",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
@@ -35,76 +35,71 @@
|
||||
},
|
||||
{
|
||||
"ordinal": 6,
|
||||
"name": "view_only",
|
||||
"type_info": "TextArray"
|
||||
},
|
||||
{
|
||||
"ordinal": 7,
|
||||
"name": "created_by",
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"ordinal": 8,
|
||||
"ordinal": 7,
|
||||
"name": "edited_at",
|
||||
"type_info": "Timestamptz"
|
||||
},
|
||||
{
|
||||
"ordinal": 9,
|
||||
"ordinal": 8,
|
||||
"name": "labels",
|
||||
"type_info": "TextArray"
|
||||
},
|
||||
{
|
||||
"ordinal": 10,
|
||||
"ordinal": 9,
|
||||
"name": "inherited_labels?",
|
||||
"type_info": "TextArray"
|
||||
},
|
||||
{
|
||||
"ordinal": 11,
|
||||
"ordinal": 10,
|
||||
"name": "is_expired",
|
||||
"type_info": "Bool"
|
||||
},
|
||||
{
|
||||
"ordinal": 12,
|
||||
"ordinal": 11,
|
||||
"name": "is_refreshed",
|
||||
"type_info": "Bool"
|
||||
},
|
||||
{
|
||||
"ordinal": 13,
|
||||
"ordinal": 12,
|
||||
"name": "refresh_error",
|
||||
"type_info": "Text"
|
||||
},
|
||||
{
|
||||
"ordinal": 14,
|
||||
"ordinal": 13,
|
||||
"name": "scopes?",
|
||||
"type_info": "TextArray"
|
||||
},
|
||||
{
|
||||
"ordinal": 15,
|
||||
"ordinal": 14,
|
||||
"name": "is_linked",
|
||||
"type_info": "Bool"
|
||||
},
|
||||
{
|
||||
"ordinal": 16,
|
||||
"ordinal": 15,
|
||||
"name": "is_oauth?",
|
||||
"type_info": "Bool"
|
||||
},
|
||||
{
|
||||
"ordinal": 17,
|
||||
"ordinal": 16,
|
||||
"name": "account",
|
||||
"type_info": "Int4"
|
||||
},
|
||||
{
|
||||
"ordinal": 18,
|
||||
"ordinal": 17,
|
||||
"name": "ws_specific",
|
||||
"type_info": "Bool"
|
||||
},
|
||||
{
|
||||
"ordinal": 19,
|
||||
"ordinal": 18,
|
||||
"name": "draft_only",
|
||||
"type_info": "Bool"
|
||||
},
|
||||
{
|
||||
"ordinal": 20,
|
||||
"ordinal": 19,
|
||||
"name": "is_draft",
|
||||
"type_info": "Bool"
|
||||
}
|
||||
@@ -122,7 +117,6 @@
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
@@ -139,5 +133,5 @@
|
||||
null
|
||||
]
|
||||
},
|
||||
"hash": "03894b75ae362139b523ddaaff21e30392acb80022005e2bb74199b5fb4375e7"
|
||||
"hash": "6e45704fddf3deb181520b295018c9c94d1f3a853529c04d786f0c1221b3fd47"
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "INSERT INTO script (\n workspace_id, hash, path, parent_hashes, summary, description, content,\n created_by, created_at, archived, schema, deleted, is_template,\n extra_perms, lock, lock_error_logs, language, kind, tag,\n envs, concurrent_limit, concurrency_time_window_s, cache_ttl,\n dedicated_worker, ws_error_handler_muted, priority, timeout,\n delete_after_use, delete_after_secs, restart_unless_cancelled, concurrency_key,\n visible_to_runner_only, auto_kind, codebase, has_preprocessor,\n on_behalf_of, on_behalf_of_email, assets, modules, job_token_scopes\n )\n SELECT\n $1, hash, path, parent_hashes, summary, description, content,\n created_by, created_at, archived, schema, deleted, is_template,\n extra_perms, lock, lock_error_logs, language, kind, tag,\n envs, concurrent_limit, concurrency_time_window_s, cache_ttl,\n dedicated_worker, ws_error_handler_muted, priority, timeout,\n delete_after_use, delete_after_secs, restart_unless_cancelled, concurrency_key,\n visible_to_runner_only, auto_kind, codebase, has_preprocessor,\n -- Same three forms and the same prefix-first rule as permissioned_as_exists,\n -- superadmin fallback included: one acting outside their workspaces has no usr\n -- row but still authenticates.\n CASE WHEN on_behalf_of LIKE 'u/%' THEN\n (SELECT on_behalf_of WHERE EXISTS (\n SELECT 1 FROM usr u WHERE u.workspace_id = $1::varchar\n AND u.username = substring(on_behalf_of from 3)\n UNION ALL\n SELECT 1 FROM password p WHERE p.super_admin\n AND (p.username = substring(on_behalf_of from 3)\n OR p.email = substring(on_behalf_of from 3))))\n WHEN on_behalf_of LIKE 'g/%' THEN\n (SELECT on_behalf_of WHERE EXISTS (\n SELECT 1 FROM group_ g WHERE g.workspace_id = $1::varchar\n AND g.name = substring(on_behalf_of from 3)))\n ELSE\n (SELECT on_behalf_of WHERE EXISTS (\n SELECT 1 FROM usr u WHERE u.workspace_id = $1::varchar\n AND u.username = on_behalf_of\n UNION ALL\n SELECT 1 FROM password p WHERE p.email = on_behalf_of\n AND p.super_admin))\n END, on_behalf_of_email, assets, modules, job_token_scopes\n FROM script\n WHERE workspace_id = $2",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Varchar",
|
||||
"Text"
|
||||
]
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "706f2227e34971d22a577b33f6aaa7f5755da9997419c4a9d07b30d4da318bea"
|
||||
}
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "UPDATE flow SET extra_perms = extra_perms - ('u/' || $2) || jsonb_build_object(('u/' || $1), extra_perms->('u/' || $2)), view_only = array_replace(view_only, 'u/' || $2, 'u/' || $1) WHERE extra_perms ? ('u/' || $2) AND workspace_id = $3",
|
||||
"query": "UPDATE flow SET extra_perms = extra_perms - ('u/' || $2) || jsonb_build_object(('u/' || $1), extra_perms->('u/' || $2)) WHERE extra_perms ? ('u/' || $2) AND workspace_id = $3",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
@@ -12,5 +12,5 @@
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "251c6463cc54705b09ecab2a155628da162490e15743c4bb9a0e8c205bee1bfa"
|
||||
"hash": "70bad6ac45db6d03c59aa375f915ec55d1c07998b1bd0268725d34f7f0b98103"
|
||||
}
|
||||
+2
-3
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "INSERT INTO folder (workspace_id, name, display_name, owners, extra_perms, view_only, summary, created_by, edited_at, default_permissioned_as, labels) VALUES ($1, $2, $3, $4, $5, $10, $6, $7, now(), $8, $9)",
|
||||
"query": "INSERT INTO folder (workspace_id, name, display_name, owners, extra_perms, summary, created_by, edited_at, default_permissioned_as, labels) VALUES ($1, $2, $3, $4, $5, $6, $7, now(), $8, $9)",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
@@ -13,11 +13,10 @@
|
||||
"Text",
|
||||
"Varchar",
|
||||
"Jsonb",
|
||||
"TextArray",
|
||||
"TextArray"
|
||||
]
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "092fb3f2bc24d2d1692a3fc4864015176899bbd9c5223d65549a8997af565152"
|
||||
"hash": "813b91a338f2fe46a7d27a155c435f33faa61710388f71f04da2d4569bc3dd71"
|
||||
}
|
||||
+4
-10
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "SELECT workspace_id, path, value, description, resource_type, extra_perms, view_only, created_by, edited_at, labels FROM resource WHERE workspace_id = $1 AND resource_type <> ALL($2)",
|
||||
"query": "SELECT workspace_id, path, value, description, resource_type, extra_perms, created_by, edited_at, labels FROM resource WHERE workspace_id = $1 AND resource_type <> ALL($2)",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
@@ -35,21 +35,16 @@
|
||||
},
|
||||
{
|
||||
"ordinal": 6,
|
||||
"name": "view_only",
|
||||
"type_info": "TextArray"
|
||||
},
|
||||
{
|
||||
"ordinal": 7,
|
||||
"name": "created_by",
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"ordinal": 8,
|
||||
"ordinal": 7,
|
||||
"name": "edited_at",
|
||||
"type_info": "Timestamptz"
|
||||
},
|
||||
{
|
||||
"ordinal": 9,
|
||||
"ordinal": 8,
|
||||
"name": "labels",
|
||||
"type_info": "TextArray"
|
||||
}
|
||||
@@ -67,11 +62,10 @@
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
true,
|
||||
true,
|
||||
true
|
||||
]
|
||||
},
|
||||
"hash": "2e897638b8b4f77d6a3e30a0f7b1fd7009ebe1082b19456d73686d076526affb"
|
||||
"hash": "825b7e301307373ecfa6b59b4091e5fe53514913562ca93de44d9ad0a02a0fe8"
|
||||
}
|
||||
-24
@@ -1,24 +0,0 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "WITH inserted AS (\n INSERT INTO flow\n (workspace_id, path, summary, description, archived, extra_perms, view_only, dependency_job, tag, ws_error_handler_muted, dedicated_worker, timeout, visible_to_runner_only, on_behalf_of, on_behalf_of_email, concurrency_key, versions, value, schema, edited_by, edited_at, labels, lock_error_logs, job_token_scopes)\n SELECT workspace_id, REGEXP_REPLACE(path, 'u/' || $2 || '/(.*)', $1 || '/\\1'), summary, description, archived, extra_perms, view_only, dependency_job, tag, ws_error_handler_muted, dedicated_worker, timeout, visible_to_runner_only, on_behalf_of, on_behalf_of_email, concurrency_key, versions, value, schema, edited_by, edited_at, labels, lock_error_logs, job_token_scopes\n FROM flow\n WHERE path LIKE ('u/' || $2 || '/%') AND workspace_id = $3\n RETURNING 1\n ) SELECT COUNT(*) FROM inserted",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "count",
|
||||
"type_info": "Int8"
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Text",
|
||||
"Text",
|
||||
"Text"
|
||||
]
|
||||
},
|
||||
"nullable": [
|
||||
null
|
||||
]
|
||||
},
|
||||
"hash": "91b82ddd4964a23bb69dcdfc5ff7f90a04016cd7fb9d249b7165f0f31c28b665"
|
||||
}
|
||||
-47
@@ -1,47 +0,0 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "WITH RECURSIVE chain(origin, id, parent_job, depth) AS (\n SELECT id, id, parent_job, 0 FROM v2_job WHERE id = ANY($1) AND workspace_id = $2\n UNION ALL\n SELECT c.origin, j.id, j.parent_job, c.depth + 1 FROM v2_job j\n JOIN chain c ON j.id = c.parent_job AND j.workspace_id = $2\n WHERE c.depth < 100\n )\n SELECT c.origin AS \"id!\", c.depth AS \"depth!\", j.created_by AS \"created_by!\",\n CASE WHEN a.agent THEN regexp_replace(j.runnable_path, '\\.chat$', '')\n ELSE j.runnable_path END AS runnable_path,\n CASE\n WHEN a.agent THEN 'agent'\n WHEN j.kind IN ('script', 'script_hub', 'unassigned_script', 'preview')\n THEN 'script'\n WHEN j.kind IN ('flow', 'unassigned_flow', 'flowpreview') THEN 'flow'\n WHEN j.kind IN ('singlestepflow', 'unassigned_singlestepflow') THEN\n CASE WHEN COALESCE(\n (SELECT m->'value'->>'type'\n FROM jsonb_array_elements(j.raw_flow->'modules') m\n WHERE m->>'id' IN ('a', 'main')\n LIMIT 1),\n 'script'\n ) = 'flow' THEN 'flow' ELSE 'script' END\n END AS acl_kind\n FROM chain c JOIN v2_job j ON j.id = c.id AND j.workspace_id = $2,\n LATERAL (SELECT j.kind = 'flowpreview'\n AND j.raw_flow->'modules'->1 IS NULL\n AND j.raw_flow->'modules'->0->>'id' = '__wm_agent_root' AS agent) a\n ORDER BY c.origin, c.depth",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "id!",
|
||||
"type_info": "Uuid"
|
||||
},
|
||||
{
|
||||
"ordinal": 1,
|
||||
"name": "depth!",
|
||||
"type_info": "Int4"
|
||||
},
|
||||
{
|
||||
"ordinal": 2,
|
||||
"name": "created_by!",
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"ordinal": 3,
|
||||
"name": "runnable_path",
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"ordinal": 4,
|
||||
"name": "acl_kind",
|
||||
"type_info": "Text"
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"UuidArray",
|
||||
"Text"
|
||||
]
|
||||
},
|
||||
"nullable": [
|
||||
null,
|
||||
null,
|
||||
false,
|
||||
null,
|
||||
null
|
||||
]
|
||||
},
|
||||
"hash": "9f4611d4968b551a9e7c33bcf383103c9ac8924bdf959602fb224bf32677df4a"
|
||||
}
|
||||
-16
@@ -1,16 +0,0 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "INSERT INTO flow\n (workspace_id, path, summary, description, archived, extra_perms, view_only, dependency_job, tag, ws_error_handler_muted, dedicated_worker, timeout, visible_to_runner_only, on_behalf_of, on_behalf_of_email, concurrency_key, versions, value, schema, edited_by, edited_at, job_token_scopes)\n SELECT workspace_id, REGEXP_REPLACE(path,'u/' || $2 || '/(.*)','u/' || $1 || '/\\1'), summary, description, archived, extra_perms, view_only, dependency_job, tag, ws_error_handler_muted, dedicated_worker, timeout, visible_to_runner_only, on_behalf_of, on_behalf_of_email, concurrency_key, versions, value, schema, edited_by, edited_at, job_token_scopes\n FROM flow\n WHERE path LIKE ('u/' || $2 || '/%') AND workspace_id = $3",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Text",
|
||||
"Text",
|
||||
"Text"
|
||||
]
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "a875cca3478a982c08e9263876a7399e3000b671a2133f9c9849a899360f1bb1"
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "SELECT name, (EXISTS (SELECT 1 FROM (SELECT key, value FROM jsonb_each_text(extra_perms) WHERE key = ANY($1)) t WHERE value IN ('true', 'write'))) as write, $1 && owners::text[] as owner FROM folder\n WHERE extra_perms ?| $1 AND workspace_id = $2",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "name",
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"ordinal": 1,
|
||||
"name": "write",
|
||||
"type_info": "Bool"
|
||||
},
|
||||
{
|
||||
"ordinal": 2,
|
||||
"name": "owner",
|
||||
"type_info": "Bool"
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"TextArray",
|
||||
"Text"
|
||||
]
|
||||
},
|
||||
"nullable": [
|
||||
false,
|
||||
null,
|
||||
null
|
||||
]
|
||||
},
|
||||
"hash": "b1f55dd2395500bfde5ca07967c7be041c6f434982519a7d0634cb4f8358001f"
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "INSERT INTO flow\n (workspace_id, path, summary, description, archived, extra_perms, dependency_job, tag, ws_error_handler_muted, dedicated_worker, timeout, visible_to_runner_only, on_behalf_of, on_behalf_of_email, concurrency_key, versions, value, schema, edited_by, edited_at, job_token_scopes)\n SELECT workspace_id, REGEXP_REPLACE(path,'u/' || $2 || '/(.*)','u/' || $1 || '/\\1'), summary, description, archived, extra_perms, dependency_job, tag, ws_error_handler_muted, dedicated_worker, timeout, visible_to_runner_only, on_behalf_of, on_behalf_of_email, concurrency_key, versions, value, schema, edited_by, edited_at, job_token_scopes\n FROM flow\n WHERE path LIKE ('u/' || $2 || '/%') AND workspace_id = $3",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Text",
|
||||
"Text",
|
||||
"Text"
|
||||
]
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "b40c9e2d637cf0f2f49fd4c720b64eb6af24e8d8aa99b846f21f2ed49c320bdc"
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "INSERT INTO resource (workspace_id, path, value, description, resource_type, extra_perms, edited_at, created_by)\n SELECT $2, path,\n CASE WHEN $3::text IS NOT NULL AND resource_type = 'ai_agent'\n AND jsonb_typeof(value) = 'object' AND value ? 'on_behalf_of'\n THEN jsonb_set(value, '{on_behalf_of}', to_jsonb($3::text))\n ELSE value END,\n description, resource_type, extra_perms, edited_at, created_by\n FROM resource\n WHERE workspace_id = $1",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Text",
|
||||
"Varchar",
|
||||
"Text"
|
||||
]
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "bf763c3ae4951537033d18ce48d3eb83d5c19e32aef199bf161e8ba8d1adf176"
|
||||
}
|
||||
-15
@@ -1,15 +0,0 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "INSERT INTO flow\n (workspace_id, path, summary, description, archived, extra_perms, view_only, dependency_job, tag, ws_error_handler_muted, dedicated_worker, timeout, visible_to_runner_only, on_behalf_of, on_behalf_of_email, concurrency_key, versions, value, schema, edited_by, edited_at, lock_error_logs, job_token_scopes)\n SELECT $1, path, summary, description, archived, extra_perms, view_only, dependency_job, tag, ws_error_handler_muted, dedicated_worker, timeout, visible_to_runner_only, on_behalf_of, on_behalf_of_email, concurrency_key, versions, value, schema, edited_by, edited_at, lock_error_logs, job_token_scopes\n FROM flow WHERE workspace_id = $2",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Varchar",
|
||||
"Text"
|
||||
]
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "c39e37756387c774e30177c2997326443d7b78639f8316c1b8e2cd27965af731"
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "WITH inserted AS (\n INSERT INTO flow\n (workspace_id, path, summary, description, archived, extra_perms, dependency_job, tag, ws_error_handler_muted, dedicated_worker, timeout, visible_to_runner_only, on_behalf_of, on_behalf_of_email, concurrency_key, versions, value, schema, edited_by, edited_at, labels, lock_error_logs, job_token_scopes)\n SELECT workspace_id, REGEXP_REPLACE(path, 'u/' || $2 || '/(.*)', $1 || '/\\1'), summary, description, archived, extra_perms, dependency_job, tag, ws_error_handler_muted, dedicated_worker, timeout, visible_to_runner_only, on_behalf_of, on_behalf_of_email, concurrency_key, versions, value, schema, edited_by, edited_at, labels, lock_error_logs, job_token_scopes\n FROM flow\n WHERE path LIKE ('u/' || $2 || '/%') AND workspace_id = $3\n RETURNING 1\n ) SELECT COUNT(*) FROM inserted",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "count",
|
||||
"type_info": "Int8"
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Text",
|
||||
"Text",
|
||||
"Text"
|
||||
]
|
||||
},
|
||||
"nullable": [
|
||||
null
|
||||
]
|
||||
},
|
||||
"hash": "c4eaa6e3b1d30a72ef1b54b2b7f28d84f1ca3c91de86d520dce06ac12d557bd5"
|
||||
}
|
||||
-15
@@ -1,15 +0,0 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "INSERT INTO script (\n workspace_id, hash, path, parent_hashes, summary, description, content,\n created_by, created_at, archived, schema, deleted, is_template,\n extra_perms, view_only, lock, lock_error_logs, language, kind, tag,\n envs, concurrent_limit, concurrency_time_window_s, cache_ttl,\n dedicated_worker, ws_error_handler_muted, priority, timeout,\n delete_after_use, delete_after_secs, restart_unless_cancelled, concurrency_key,\n visible_to_runner_only, auto_kind, codebase, has_preprocessor,\n on_behalf_of, on_behalf_of_email, assets, modules, job_token_scopes\n )\n SELECT\n $1, hash, path, parent_hashes, summary, description, content,\n created_by, created_at, archived, schema, deleted, is_template,\n extra_perms, view_only, lock, lock_error_logs, language, kind, tag,\n envs, concurrent_limit, concurrency_time_window_s, cache_ttl,\n dedicated_worker, ws_error_handler_muted, priority, timeout,\n delete_after_use, delete_after_secs, restart_unless_cancelled, concurrency_key,\n visible_to_runner_only, auto_kind, codebase, has_preprocessor,\n -- Same three forms and the same prefix-first rule as permissioned_as_exists,\n -- superadmin fallback included: one acting outside their workspaces has no usr\n -- row but still authenticates.\n CASE WHEN on_behalf_of LIKE 'u/%' THEN\n (SELECT on_behalf_of WHERE EXISTS (\n SELECT 1 FROM usr u WHERE u.workspace_id = $1::varchar\n AND u.username = substring(on_behalf_of from 3)\n UNION ALL\n SELECT 1 FROM password p WHERE p.super_admin\n AND (p.username = substring(on_behalf_of from 3)\n OR p.email = substring(on_behalf_of from 3))))\n WHEN on_behalf_of LIKE 'g/%' THEN\n (SELECT on_behalf_of WHERE EXISTS (\n SELECT 1 FROM group_ g WHERE g.workspace_id = $1::varchar\n AND g.name = substring(on_behalf_of from 3)))\n ELSE\n (SELECT on_behalf_of WHERE EXISTS (\n SELECT 1 FROM usr u WHERE u.workspace_id = $1::varchar\n AND u.username = on_behalf_of\n UNION ALL\n SELECT 1 FROM password p WHERE p.email = on_behalf_of\n AND p.super_admin))\n END, on_behalf_of_email, assets, modules, job_token_scopes\n FROM script\n WHERE workspace_id = $2",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Varchar",
|
||||
"Text"
|
||||
]
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "c7841d246e0a53979507c278d606258c1635506d4d0edd9d9c3d40fc38cabf88"
|
||||
}
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "UPDATE folder SET extra_perms = extra_perms - ('u/' || $2) || jsonb_build_object(('u/' || $1), extra_perms->('u/' || $2)), view_only = array_replace(view_only, 'u/' || $2, 'u/' || $1) WHERE extra_perms ? ('u/' || $2) AND workspace_id = $3",
|
||||
"query": "UPDATE folder SET extra_perms = extra_perms - ('u/' || $2) || jsonb_build_object(('u/' || $1), extra_perms->('u/' || $2)) WHERE extra_perms ? ('u/' || $2) AND workspace_id = $3",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
@@ -12,5 +12,5 @@
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "924b4941829f69ff96c55f0a432298de7cf3aa1690c931a5b569fce3203a86c3"
|
||||
"hash": "cc9e2460b8fded240eff64cf3cf348f9bd36a86233f3b0a3e73f51698ed353dd"
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "WITH RECURSIVE chain(origin, id, parent_job, depth) AS (\n SELECT id, id, parent_job, 0 FROM v2_job WHERE id = ANY($1) AND workspace_id = $2\n UNION ALL\n SELECT c.origin, j.id, j.parent_job, c.depth + 1 FROM v2_job j\n JOIN chain c ON j.id = c.parent_job AND j.workspace_id = $2\n WHERE c.depth < 100\n )\n SELECT c.origin AS \"id!\", j.created_by AS \"created_by!\",\n CASE WHEN a.agent THEN regexp_replace(j.runnable_path, '\\.chat$', '')\n ELSE j.runnable_path END AS runnable_path,\n CASE\n WHEN a.agent THEN 'agent'\n WHEN j.kind IN ('script', 'script_hub', 'unassigned_script', 'preview')\n THEN 'script'\n WHEN j.kind IN ('flow', 'unassigned_flow', 'flowpreview') THEN 'flow'\n WHEN j.kind IN ('singlestepflow', 'unassigned_singlestepflow') THEN\n CASE WHEN COALESCE(\n (SELECT m->'value'->>'type'\n FROM jsonb_array_elements(j.raw_flow->'modules') m\n WHERE m->>'id' IN ('a', 'main')\n LIMIT 1),\n 'script'\n ) = 'flow' THEN 'flow' ELSE 'script' END\n END AS acl_kind\n FROM chain c JOIN v2_job j ON j.id = c.id AND j.workspace_id = $2,\n LATERAL (SELECT j.kind = 'flowpreview'\n AND j.raw_flow->'modules'->1 IS NULL\n AND j.raw_flow->'modules'->0->>'id' = '__wm_agent_root' AS agent) a\n ORDER BY c.origin, c.depth",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "id!",
|
||||
"type_info": "Uuid"
|
||||
},
|
||||
{
|
||||
"ordinal": 1,
|
||||
"name": "created_by!",
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"ordinal": 2,
|
||||
"name": "runnable_path",
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"ordinal": 3,
|
||||
"name": "acl_kind",
|
||||
"type_info": "Text"
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"UuidArray",
|
||||
"Text"
|
||||
]
|
||||
},
|
||||
"nullable": [
|
||||
null,
|
||||
false,
|
||||
null,
|
||||
null
|
||||
]
|
||||
},
|
||||
"hash": "d64af095618cdfd5e8a5a2ad3b714ad64feb4129a0117d2789346ebd370d33a2"
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "INSERT INTO flow (\n workspace_id, path, summary, description, value, edited_by, edited_at,\n archived, schema, extra_perms, dependency_job, tag,\n ws_error_handler_muted, dedicated_worker, timeout, visible_to_runner_only,\n concurrency_key, versions, on_behalf_of, on_behalf_of_email, lock_error_logs,\n job_token_scopes\n )\n SELECT $2, path, summary, description, value, edited_by, edited_at,\n archived, schema, extra_perms, NULL, tag,\n ws_error_handler_muted, dedicated_worker, timeout, visible_to_runner_only,\n concurrency_key, ARRAY[]::bigint[],\n -- Same predicate as clone_scripts.\n CASE WHEN on_behalf_of LIKE 'u/%' THEN\n (SELECT on_behalf_of WHERE EXISTS (\n SELECT 1 FROM usr u WHERE u.workspace_id = $2::varchar\n AND u.username = substring(on_behalf_of from 3)\n UNION ALL\n SELECT 1 FROM password p WHERE p.super_admin\n AND (p.username = substring(on_behalf_of from 3)\n OR p.email = substring(on_behalf_of from 3))))\n WHEN on_behalf_of LIKE 'g/%' THEN\n (SELECT on_behalf_of WHERE EXISTS (\n SELECT 1 FROM group_ g WHERE g.workspace_id = $2::varchar\n AND g.name = substring(on_behalf_of from 3)))\n ELSE\n (SELECT on_behalf_of WHERE EXISTS (\n SELECT 1 FROM usr u WHERE u.workspace_id = $2::varchar\n AND u.username = on_behalf_of\n UNION ALL\n SELECT 1 FROM password p WHERE p.email = on_behalf_of\n AND p.super_admin))\n END, on_behalf_of_email, lock_error_logs, job_token_scopes\n FROM flow\n WHERE workspace_id = $1",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Text",
|
||||
"Varchar"
|
||||
]
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "df1fe2e7ef004b8de0e626f40fd737b3b4b662a89148cf6ac70eb3563ad7f0c5"
|
||||
}
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "UPDATE script SET extra_perms = extra_perms - ('u/' || $2) || jsonb_build_object(('u/' || $1), extra_perms->('u/' || $2)), view_only = array_replace(view_only, 'u/' || $2, 'u/' || $1) WHERE extra_perms ? ('u/' || $2) AND workspace_id = $3",
|
||||
"query": "UPDATE script SET extra_perms = extra_perms - ('u/' || $2) || jsonb_build_object(('u/' || $1), extra_perms->('u/' || $2)) WHERE extra_perms ? ('u/' || $2) AND workspace_id = $3",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
@@ -12,5 +12,5 @@
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "a6deb6191f84b084cb523c7385a3977c15deffa9e484945e53d8e0aa46f1fbc1"
|
||||
"hash": "e38dd0f093636efa2ec1cda4618fc104f7b8ea88130692ce9c1390bda289627a"
|
||||
}
|
||||
-16
@@ -1,16 +0,0 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "INSERT INTO flow\n (workspace_id, path, summary, description, archived, extra_perms, view_only, dependency_job, tag, ws_error_handler_muted, dedicated_worker, timeout, visible_to_runner_only, on_behalf_of, on_behalf_of_email, concurrency_key, versions, value, schema, edited_by, edited_at, labels, job_token_scopes)\n SELECT workspace_id, $1, summary, description, archived, extra_perms, view_only, dependency_job, tag, ws_error_handler_muted, dedicated_worker, timeout, visible_to_runner_only, on_behalf_of, on_behalf_of_email, concurrency_key, versions, value, schema, edited_by, edited_at, labels, job_token_scopes\n FROM flow\n WHERE path = $2 AND workspace_id = $3",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Varchar",
|
||||
"Text",
|
||||
"Text"
|
||||
]
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "e6818d4b9ea9991b252f5771c3fe2c8c7043e89e5fae70613c8230d94a183f6c"
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "INSERT INTO flow\n (workspace_id, path, summary, description, archived, extra_perms, dependency_job, tag, ws_error_handler_muted, dedicated_worker, timeout, visible_to_runner_only, on_behalf_of, on_behalf_of_email, concurrency_key, versions, value, schema, edited_by, edited_at, lock_error_logs, job_token_scopes)\n SELECT $1, path, summary, description, archived, extra_perms, dependency_job, tag, ws_error_handler_muted, dedicated_worker, timeout, visible_to_runner_only, on_behalf_of, on_behalf_of_email, concurrency_key, versions, value, schema, edited_by, edited_at, lock_error_logs, job_token_scopes\n FROM flow WHERE workspace_id = $2",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Varchar",
|
||||
"Text"
|
||||
]
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "e81eaa501b4af1269a4929ec660d10fc10d9ec4dc2359f43d79fe255d101cad8"
|
||||
}
|
||||
-15
@@ -1,15 +0,0 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "INSERT INTO folder (name, workspace_id, display_name, owners, extra_perms, view_only, summary, edited_at, created_by, default_permissioned_as, labels) SELECT name, $1, display_name, owners, extra_perms, view_only, summary, edited_at, created_by, default_permissioned_as, labels FROM folder WHERE workspace_id = $2",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Varchar",
|
||||
"Text"
|
||||
]
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "f0a7de33927a3c1ec11387870f5e17d56a1c7c403a2dcbe4335ace15798b2e86"
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
DROP FUNCTION acl_grants_run(JSONB, TEXT[]);
|
||||
|
||||
-- Back to booleans, so the casts below hold: a view-only grant becomes a read grant, which runs.
|
||||
DO $$
|
||||
DECLARE t TEXT;
|
||||
BEGIN
|
||||
FOREACH t IN ARRAY ARRAY['script', 'flow', 'resource', 'folder'] LOOP
|
||||
EXECUTE format($p$UPDATE %1$I SET extra_perms = (
|
||||
SELECT jsonb_object_agg(key, value IN ('true', 'write'))
|
||||
FROM jsonb_each_text(extra_perms))
|
||||
WHERE EXISTS (SELECT 1 FROM jsonb_each(extra_perms) e
|
||||
WHERE jsonb_typeof(e.value) = 'string')$p$, t);
|
||||
END LOOP;
|
||||
FOREACH t IN ARRAY ARRAY['script', 'flow', 'resource'] LOOP
|
||||
EXECUTE format($p$ALTER POLICY see_extra_perms_user_insert ON %1$I WITH CHECK (
|
||||
((extra_perms ->> (SELECT concat('u/', current_setting('session.user')))))::boolean)$p$, t);
|
||||
EXECUTE format($p$ALTER POLICY see_extra_perms_user_update ON %1$I USING (
|
||||
((extra_perms ->> (SELECT concat('u/', current_setting('session.user')))))::boolean)$p$, t);
|
||||
EXECUTE format($p$ALTER POLICY see_extra_perms_user_delete ON %1$I USING (
|
||||
((extra_perms ->> (SELECT concat('u/', current_setting('session.user')))))::boolean)$p$, t);
|
||||
EXECUTE format($p$ALTER POLICY see_extra_perms_groups_insert ON %1$I WITH CHECK (
|
||||
EXISTS (SELECT 1 FROM jsonb_each_text(%1$I.extra_perms) e
|
||||
WHERE split_part(e.key, '/', 1) = 'g'
|
||||
AND e.key = ANY ((SELECT regexp_split_to_array(
|
||||
current_setting('session.pgroups'), ','))::text[])
|
||||
AND e.value::boolean))$p$, t);
|
||||
EXECUTE format($p$ALTER POLICY see_extra_perms_groups_update ON %1$I USING (
|
||||
EXISTS (SELECT 1 FROM jsonb_each_text(%1$I.extra_perms) e
|
||||
WHERE split_part(e.key, '/', 1) = 'g'
|
||||
AND e.key = ANY ((SELECT regexp_split_to_array(
|
||||
current_setting('session.pgroups'), ','))::text[])
|
||||
AND e.value::boolean))$p$, t);
|
||||
EXECUTE format($p$ALTER POLICY see_extra_perms_groups_delete ON %1$I USING (
|
||||
EXISTS (SELECT 1 FROM jsonb_each_text(%1$I.extra_perms) e
|
||||
WHERE split_part(e.key, '/', 1) = 'g'
|
||||
AND e.key = ANY ((SELECT regexp_split_to_array(
|
||||
current_setting('session.pgroups'), ','))::text[])
|
||||
AND e.value::boolean))$p$, t);
|
||||
END LOOP;
|
||||
END $$;
|
||||
@@ -0,0 +1,45 @@
|
||||
-- A grant in `extra_perms` is `true` (write), `false` (the level below write: run where the
|
||||
-- item runs, read elsewhere) or one of "read", "run", "write". These policies read it without
|
||||
-- the boolean cast they had, which a string value would make fail for every writer of the row.
|
||||
DO $$
|
||||
DECLARE t TEXT;
|
||||
BEGIN
|
||||
FOREACH t IN ARRAY ARRAY['script', 'flow', 'resource'] LOOP
|
||||
EXECUTE format($p$ALTER POLICY see_extra_perms_user_insert ON %1$I WITH CHECK (
|
||||
(extra_perms ->> (SELECT concat('u/', current_setting('session.user'))))
|
||||
IN ('true', 'write'))$p$, t);
|
||||
EXECUTE format($p$ALTER POLICY see_extra_perms_user_update ON %1$I USING (
|
||||
(extra_perms ->> (SELECT concat('u/', current_setting('session.user'))))
|
||||
IN ('true', 'write'))$p$, t);
|
||||
EXECUTE format($p$ALTER POLICY see_extra_perms_user_delete ON %1$I USING (
|
||||
(extra_perms ->> (SELECT concat('u/', current_setting('session.user'))))
|
||||
IN ('true', 'write'))$p$, t);
|
||||
EXECUTE format($p$ALTER POLICY see_extra_perms_groups_insert ON %1$I WITH CHECK (
|
||||
EXISTS (SELECT 1 FROM jsonb_each_text(%1$I.extra_perms) e
|
||||
WHERE split_part(e.key, '/', 1) = 'g'
|
||||
AND e.key = ANY ((SELECT regexp_split_to_array(
|
||||
current_setting('session.pgroups'), ','))::text[])
|
||||
AND e.value IN ('true', 'write')))$p$, t);
|
||||
EXECUTE format($p$ALTER POLICY see_extra_perms_groups_update ON %1$I USING (
|
||||
EXISTS (SELECT 1 FROM jsonb_each_text(%1$I.extra_perms) e
|
||||
WHERE split_part(e.key, '/', 1) = 'g'
|
||||
AND e.key = ANY ((SELECT regexp_split_to_array(
|
||||
current_setting('session.pgroups'), ','))::text[])
|
||||
AND e.value IN ('true', 'write')))$p$, t);
|
||||
EXECUTE format($p$ALTER POLICY see_extra_perms_groups_delete ON %1$I USING (
|
||||
EXISTS (SELECT 1 FROM jsonb_each_text(%1$I.extra_perms) e
|
||||
WHERE split_part(e.key, '/', 1) = 'g'
|
||||
AND e.key = ANY ((SELECT regexp_split_to_array(
|
||||
current_setting('session.pgroups'), ','))::text[])
|
||||
AND e.value IN ('true', 'write')))$p$, t);
|
||||
END LOOP;
|
||||
END $$;
|
||||
|
||||
-- Whether any of `principals` holds a grant in `extra_perms` of a runnable that includes running.
|
||||
CREATE FUNCTION acl_grants_run(extra_perms JSONB, principals TEXT[])
|
||||
RETURNS BOOLEAN LANGUAGE sql IMMUTABLE AS $$
|
||||
SELECT EXISTS (
|
||||
SELECT 1 FROM jsonb_each_text(extra_perms) e
|
||||
WHERE e.key = ANY(principals) AND e.value <> 'read'
|
||||
)
|
||||
$$;
|
||||
@@ -1,5 +0,0 @@
|
||||
DROP FUNCTION acl_grants_run(JSONB, TEXT[], TEXT[]);
|
||||
ALTER TABLE script DROP COLUMN view_only;
|
||||
ALTER TABLE flow DROP COLUMN view_only;
|
||||
ALTER TABLE resource DROP COLUMN view_only;
|
||||
ALTER TABLE folder DROP COLUMN view_only;
|
||||
@@ -1,15 +0,0 @@
|
||||
-- Principals of `extra_perms` whose read grant does not include running. Empty for every
|
||||
-- existing row, so every existing read grant keeps running.
|
||||
ALTER TABLE script ADD COLUMN view_only TEXT[] NOT NULL DEFAULT '{}';
|
||||
ALTER TABLE flow ADD COLUMN view_only TEXT[] NOT NULL DEFAULT '{}';
|
||||
ALTER TABLE resource ADD COLUMN view_only TEXT[] NOT NULL DEFAULT '{}';
|
||||
ALTER TABLE folder ADD COLUMN view_only TEXT[] NOT NULL DEFAULT '{}';
|
||||
|
||||
-- Whether any of `principals` holds a grant in `extra_perms` that includes running.
|
||||
CREATE FUNCTION acl_grants_run(extra_perms JSONB, view_only TEXT[], principals TEXT[])
|
||||
RETURNS BOOLEAN LANGUAGE sql IMMUTABLE AS $$
|
||||
SELECT EXISTS (
|
||||
SELECT 1 FROM jsonb_each_text(extra_perms) e
|
||||
WHERE e.key = ANY(principals) AND (e.value::boolean OR NOT e.key = ANY(view_only))
|
||||
)
|
||||
$$;
|
||||
@@ -169,7 +169,6 @@ async fn list_flows(
|
||||
"fv.created_at as edited_at",
|
||||
"archived",
|
||||
"extra_perms",
|
||||
"o.view_only",
|
||||
"favorite.path IS NOT NULL as starred",
|
||||
"ws_error_handler_muted",
|
||||
"o.labels",
|
||||
@@ -313,7 +312,6 @@ async fn list_flows(
|
||||
edited_at: Some(row.created_at),
|
||||
archived: false,
|
||||
extra_perms: serde_json::Value::Object(serde_json::Map::new()),
|
||||
view_only: vec![],
|
||||
starred: false,
|
||||
draft_only: Some(true),
|
||||
ws_error_handler_muted: None,
|
||||
@@ -1116,7 +1114,7 @@ async fn get_flow_version(
|
||||
let mut tx = user_db.begin(&authed).await?;
|
||||
|
||||
let flow = sqlx::query_as::<_, Flow>(
|
||||
"SELECT flow.workspace_id, flow.path, flow.summary, flow.description, flow.archived, flow.extra_perms, flow.view_only, flow.dedicated_worker, flow.tag, flow.ws_error_handler_muted, flow.timeout, flow.visible_to_runner_only, flow.on_behalf_of, flow.labels, flow.job_token_scopes, flow_version.schema, flow_version.value, flow_version.created_at as edited_at, flow_version.created_by as edited_by
|
||||
"SELECT flow.workspace_id, flow.path, flow.summary, flow.description, flow.archived, flow.extra_perms, flow.dedicated_worker, flow.tag, flow.ws_error_handler_muted, flow.timeout, flow.visible_to_runner_only, flow.on_behalf_of, flow.labels, flow.job_token_scopes, flow_version.schema, flow_version.value, flow_version.created_at as edited_at, flow_version.created_by as edited_by
|
||||
FROM flow
|
||||
LEFT JOIN flow_version ON flow_version.path = flow.path AND flow_version.workspace_id = flow.workspace_id
|
||||
WHERE flow.path = $1 AND flow.workspace_id = $2 AND flow_version.id = $3",
|
||||
@@ -1168,7 +1166,7 @@ async fn get_flow_version_by_id(
|
||||
flow.summary,
|
||||
flow.description,
|
||||
flow.archived,
|
||||
flow.extra_perms, flow.view_only,
|
||||
flow.extra_perms,
|
||||
flow.dedicated_worker,
|
||||
flow.tag,
|
||||
flow.ws_error_handler_muted,
|
||||
@@ -1431,8 +1429,8 @@ async fn update_flow(
|
||||
// if new path, must clone flow to new path and delete old flow for flow_version foreign key constraint
|
||||
sqlx::query!(
|
||||
"INSERT INTO flow
|
||||
(workspace_id, path, summary, description, archived, extra_perms, view_only, dependency_job, tag, ws_error_handler_muted, dedicated_worker, timeout, visible_to_runner_only, on_behalf_of, on_behalf_of_email, concurrency_key, versions, value, schema, edited_by, edited_at, labels, job_token_scopes)
|
||||
SELECT workspace_id, $1, summary, description, archived, extra_perms, view_only, dependency_job, tag, ws_error_handler_muted, dedicated_worker, timeout, visible_to_runner_only, on_behalf_of, on_behalf_of_email, concurrency_key, versions, value, schema, edited_by, edited_at, labels, job_token_scopes
|
||||
(workspace_id, path, summary, description, archived, extra_perms, dependency_job, tag, ws_error_handler_muted, dedicated_worker, timeout, visible_to_runner_only, on_behalf_of, on_behalf_of_email, concurrency_key, versions, value, schema, edited_by, edited_at, labels, job_token_scopes)
|
||||
SELECT workspace_id, $1, summary, description, archived, extra_perms, dependency_job, tag, ws_error_handler_muted, dedicated_worker, timeout, visible_to_runner_only, on_behalf_of, on_behalf_of_email, concurrency_key, versions, value, schema, edited_by, edited_at, labels, job_token_scopes
|
||||
FROM flow
|
||||
WHERE path = $2 AND workspace_id = $3",
|
||||
nf.path,
|
||||
@@ -1884,7 +1882,7 @@ async fn get_flow_by_path(
|
||||
flow.summary,
|
||||
flow.description,
|
||||
flow.archived,
|
||||
flow.extra_perms, flow.view_only,
|
||||
flow.extra_perms,
|
||||
flow.dedicated_worker,
|
||||
flow.tag,
|
||||
flow.ws_error_handler_muted,
|
||||
@@ -1926,7 +1924,7 @@ async fn get_flow_by_path(
|
||||
flow.summary,
|
||||
flow.description,
|
||||
flow.archived,
|
||||
flow.extra_perms, flow.view_only,
|
||||
flow.extra_perms,
|
||||
flow.dedicated_worker,
|
||||
flow.tag,
|
||||
flow.ws_error_handler_muted,
|
||||
|
||||
@@ -137,11 +137,11 @@ fn items_query() -> String {
|
||||
(split_part(i.path, '/', 1) = 'u' AND split_part(i.path, '/', 2) = s.usr) AS own,
|
||||
CASE WHEN split_part(i.path, '/', 1) = 'g' AND split_part(i.path, '/', 2) = ANY(s.groups)
|
||||
THEN split_part(i.path, '/', 2) END AS path_group,
|
||||
(i.extra_perms ->> ('u/' || s.usr))::boolean AS user_grant,
|
||||
(i.extra_perms ->> ('u/' || s.usr)) IN ('true', 'write') AS user_grant,
|
||||
ARRAY(SELECT substr(e.key, 3) FROM jsonb_each_text(i.extra_perms) e
|
||||
WHERE e.key = ANY(s.pgroups) ORDER BY e.key) AS group_read,
|
||||
ARRAY(SELECT substr(e.key, 3) FROM jsonb_each_text(i.extra_perms) e
|
||||
WHERE e.key = ANY(s.pgroups) AND e.value::boolean ORDER BY e.key) AS group_write,
|
||||
WHERE e.key = ANY(s.pgroups) AND e.value IN ('true', 'write') ORDER BY e.key) AS group_write,
|
||||
CASE WHEN split_part(i.path, '/', 1) = 'f' AND split_part(i.path, '/', 2) = ANY(s.fr)
|
||||
THEN split_part(i.path, '/', 2) END AS folder,
|
||||
(split_part(i.path, '/', 1) = 'f' AND split_part(i.path, '/', 2) = ANY(s.fw)) AS folder_write
|
||||
|
||||
@@ -60,9 +60,6 @@ pub struct Folder {
|
||||
pub display_name: String,
|
||||
pub owners: Vec<String>,
|
||||
pub extra_perms: serde_json::Value,
|
||||
/// Principals of `extra_perms` that may view but not run what the folder holds.
|
||||
#[serde(default)]
|
||||
pub view_only: Vec<String>,
|
||||
pub summary: Option<String>,
|
||||
pub created_by: Option<String>,
|
||||
pub edited_at: Option<chrono::DateTime<chrono::Utc>>,
|
||||
@@ -78,7 +75,6 @@ pub struct NewFolder {
|
||||
pub display_name: Option<String>,
|
||||
pub owners: Option<Vec<String>>,
|
||||
pub extra_perms: Option<serde_json::Value>,
|
||||
pub view_only: Option<Vec<String>>,
|
||||
pub default_permissioned_as: Option<serde_json::Value>,
|
||||
pub labels: Option<Vec<String>>,
|
||||
}
|
||||
@@ -89,9 +85,6 @@ pub struct UpdateFolder {
|
||||
pub display_name: Option<String>,
|
||||
pub owners: Option<Vec<String>>,
|
||||
pub extra_perms: Option<serde_json::Value>,
|
||||
/// `None` keeps the stored list: git sync posts a folder file whole, and one written before
|
||||
/// view-only grants existed must not turn every viewer into a runner.
|
||||
pub view_only: Option<Vec<String>>,
|
||||
pub default_permissioned_as: Option<serde_json::Value>,
|
||||
pub labels: Option<Vec<String>>,
|
||||
}
|
||||
@@ -122,7 +115,7 @@ async fn list_folders(
|
||||
let allowed = build_scope_path_predicate(&authed, "folders", "read");
|
||||
let rows = sqlx::query_as!(
|
||||
Folder,
|
||||
"SELECT workspace_id, name, display_name, owners, extra_perms, view_only, summary, created_by, edited_at, default_permissioned_as, labels FROM folder WHERE workspace_id = $1 ORDER BY name asc LIMIT $2 OFFSET $3",
|
||||
"SELECT workspace_id, name, display_name, owners, extra_perms, summary, created_by, edited_at, default_permissioned_as, labels FROM folder WHERE workspace_id = $1 ORDER BY name asc LIMIT $2 OFFSET $3",
|
||||
w_id,
|
||||
per_page as i64,
|
||||
offset as i64
|
||||
@@ -320,6 +313,7 @@ async fn create_folder(
|
||||
.unwrap_or_else(|| serde_json::Value::Object(serde_json::Map::new()));
|
||||
|
||||
if extra_perms.is_object() {
|
||||
normalize_acl_values(&mut extra_perms)?;
|
||||
let extra_mut = extra_perms.as_object_mut().unwrap();
|
||||
for o in &owners {
|
||||
extra_mut.insert(o.clone(), serde_json::json!(true));
|
||||
@@ -338,7 +332,7 @@ async fn create_folder(
|
||||
if let Err(e) =
|
||||
sqlx::query_as!(
|
||||
Folder,
|
||||
"INSERT INTO folder (workspace_id, name, display_name, owners, extra_perms, view_only, summary, created_by, edited_at, default_permissioned_as, labels) VALUES ($1, $2, $3, $4, $5, $10, $6, $7, now(), $8, $9)",
|
||||
"INSERT INTO folder (workspace_id, name, display_name, owners, extra_perms, summary, created_by, edited_at, default_permissioned_as, labels) VALUES ($1, $2, $3, $4, $5, $6, $7, now(), $8, $9)",
|
||||
w_id,
|
||||
ng.name,
|
||||
ng.display_name.unwrap_or(ng.name.clone()),
|
||||
@@ -347,12 +341,7 @@ async fn create_folder(
|
||||
ng.summary,
|
||||
authed.username,
|
||||
default_permissioned_as,
|
||||
ng.labels.as_deref().filter(|l| !l.is_empty()) as Option<&[String]>,
|
||||
&ng.view_only
|
||||
.unwrap_or_default()
|
||||
.into_iter()
|
||||
.filter(|p| extra_perms.get(p) == Some(&serde_json::json!(false)))
|
||||
.collect::<Vec<_>>(),
|
||||
ng.labels.as_deref().filter(|l| !l.is_empty()) as Option<&[String]>
|
||||
)
|
||||
.execute(&mut *tx)
|
||||
.await {
|
||||
@@ -461,11 +450,7 @@ async fn update_folder(
|
||||
|
||||
// update_folder can also grant permissions (owners / extra_perms / default_permissioned_as),
|
||||
// so it is a sharing path and must honor the demo-workspace sharing restriction.
|
||||
if ng.owners.is_some()
|
||||
|| ng.extra_perms.is_some()
|
||||
|| ng.view_only.is_some()
|
||||
|| ng.default_permissioned_as.is_some()
|
||||
{
|
||||
if ng.owners.is_some() || ng.extra_perms.is_some() || ng.default_permissioned_as.is_some() {
|
||||
crate::check_demo_workspace_restriction(&authed, &w_id, "Sharing")?;
|
||||
}
|
||||
|
||||
@@ -519,34 +504,20 @@ async fn update_folder(
|
||||
)),
|
||||
);
|
||||
}
|
||||
if let Some(extra_perms) = ng.extra_perms {
|
||||
if let Some(mut extra_perms) = ng.extra_perms {
|
||||
if !extra_perms.is_object() {
|
||||
return Err(windmill_common::error::Error::BadRequest(format!(
|
||||
"extra_perms must be an object, received {}",
|
||||
extra_perms.to_string()
|
||||
)));
|
||||
}
|
||||
normalize_acl_values(&mut extra_perms)?;
|
||||
sqlb.set(
|
||||
"extra_perms",
|
||||
"?".bind(&serde_json::to_string(&extra_perms).map_err(to_anyhow)?),
|
||||
);
|
||||
}
|
||||
|
||||
let view_only_changed = ng.view_only.is_some();
|
||||
if let Some(view_only) = ng.view_only.as_ref() {
|
||||
sqlb.set(
|
||||
"view_only",
|
||||
"?".bind(&format!(
|
||||
"{{{}}}",
|
||||
view_only
|
||||
.iter()
|
||||
.map(|x| format!("\"{}\"", x.replace('\\', "\\\\").replace('"', "\\\"")))
|
||||
.collect::<Vec<_>>()
|
||||
.join(","),
|
||||
)),
|
||||
);
|
||||
}
|
||||
|
||||
if let Some(default_permissioned_as) = ng.default_permissioned_as.as_ref() {
|
||||
validate_default_permissioned_as(default_permissioned_as)?;
|
||||
sqlb.set(
|
||||
@@ -597,8 +568,7 @@ async fn update_folder(
|
||||
for o in nfolder.owners {
|
||||
if !extra_perms
|
||||
.get(&o)
|
||||
.and_then(|x| x.as_bool())
|
||||
.unwrap_or(false)
|
||||
.is_some_and(windmill_common::auth::acl_writes)
|
||||
{
|
||||
return Err(windmill_common::error::Error::BadRequest(format!(
|
||||
"Owner {} would not have permission to write to folder and that is an invalid state",
|
||||
@@ -631,12 +601,11 @@ async fn update_folder(
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
if extra_perms_changed || view_only_changed {
|
||||
if extra_perms_changed {
|
||||
log_folder_permission_change(&mut *tx, &w_id, &name, &authed.username, "update_acl", None)
|
||||
.await?;
|
||||
prune_view_only(&mut *tx, &w_id, &name).await?;
|
||||
}
|
||||
if owners_changed || extra_perms_changed || view_only_changed {
|
||||
if owners_changed || extra_perms_changed {
|
||||
windmill_common::auth::notify_run_perms_change(&mut *tx).await?;
|
||||
}
|
||||
if default_permissioned_as_changed {
|
||||
@@ -655,7 +624,7 @@ async fn update_folder(
|
||||
}
|
||||
|
||||
tx.commit().await?;
|
||||
if owners_changed || extra_perms_changed || view_only_changed {
|
||||
if owners_changed || extra_perms_changed {
|
||||
windmill_common::auth::invalidate_run_perms_cache();
|
||||
}
|
||||
|
||||
@@ -686,7 +655,7 @@ pub async fn get_folderopt<'c>(
|
||||
) -> Result<Option<Folder>> {
|
||||
let folderopt = sqlx::query_as!(
|
||||
Folder,
|
||||
"SELECT workspace_id, name, display_name, owners, extra_perms, view_only, summary, created_by, edited_at, default_permissioned_as, labels FROM folder WHERE name = $1 AND workspace_id = $2",
|
||||
"SELECT workspace_id, name, display_name, owners, extra_perms, summary, created_by, edited_at, default_permissioned_as, labels FROM folder WHERE name = $1 AND workspace_id = $2",
|
||||
name,
|
||||
w_id
|
||||
)
|
||||
@@ -928,7 +897,6 @@ async fn add_owner(
|
||||
.bind(&owner)
|
||||
.fetch_optional(&mut *tx)
|
||||
.await?;
|
||||
prune_view_only(&mut *tx, &w_id, &name).await?;
|
||||
|
||||
audit_log(
|
||||
&mut *tx,
|
||||
@@ -1013,7 +981,7 @@ async fn remove_owner(
|
||||
if let Some(write) = write {
|
||||
let old_write = sqlx::query_scalar::<_, Option<bool>>(
|
||||
"UPDATE folder SET extra_perms = jsonb_set(extra_perms, array[$4]::text[], to_jsonb($1), \
|
||||
true) FROM (SELECT (extra_perms->>$4)::boolean as old_val FROM folder WHERE name = $2 AND workspace_id = $3) old \
|
||||
true) FROM (SELECT (extra_perms->>$4) IN ('true', 'write') as old_val FROM folder WHERE name = $2 AND workspace_id = $3) old \
|
||||
WHERE name = $2 AND workspace_id = $3 RETURNING old.old_val"
|
||||
)
|
||||
.bind(write)
|
||||
@@ -1030,7 +998,6 @@ async fn remove_owner(
|
||||
owner, name, write
|
||||
));
|
||||
}
|
||||
prune_view_only(&mut *tx, &w_id, &name).await?;
|
||||
}
|
||||
|
||||
audit_log(
|
||||
@@ -1104,18 +1071,22 @@ pub async fn log_folder_permission_change<'c, E: sqlx::Executor<'c, Database = P
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Keeps in `view_only` only principals still holding a read grant, so replacing a folder's
|
||||
/// grants cannot leave a stale entry that a later read grant would silently pick up.
|
||||
async fn prune_view_only(tx: &mut sqlx::PgConnection, w_id: &str, name: &str) -> Result<()> {
|
||||
sqlx::query!(
|
||||
"UPDATE folder SET view_only = ARRAY(
|
||||
SELECT v FROM unnest(view_only) v WHERE extra_perms->>v = 'false'
|
||||
) WHERE name = $1 AND workspace_id = $2",
|
||||
name,
|
||||
w_id
|
||||
)
|
||||
.execute(tx)
|
||||
.await?;
|
||||
/// Accepts each grant as `true`, `false`, `"read"`, `"run"` or `"write"`, and stores it the way
|
||||
/// `/acls/add` does: booleans for run and write, which every client reads, `"read"` otherwise.
|
||||
fn normalize_acl_values(extra_perms: &mut serde_json::Value) -> Result<()> {
|
||||
for (owner, v) in extra_perms.as_object_mut().into_iter().flatten() {
|
||||
*v = match &*v {
|
||||
serde_json::Value::Bool(_) => continue,
|
||||
serde_json::Value::String(l) if l == "read" => continue,
|
||||
serde_json::Value::String(l) if l == "run" => serde_json::json!(false),
|
||||
serde_json::Value::String(l) if l == "write" => serde_json::json!(true),
|
||||
_ => {
|
||||
return Err(error::Error::BadRequest(format!(
|
||||
"Invalid grant for {owner}: {v}, expected true, false, \"read\", \"run\" or \"write\""
|
||||
)))
|
||||
}
|
||||
};
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
@@ -88,7 +88,6 @@ const KINDS: [&str; 21] = [
|
||||
pub fn workspaced_service() -> Router {
|
||||
Router::new()
|
||||
.route("/get/{*path}", get(get_granular_acls))
|
||||
.route("/get_view_only/{*path}", get(get_granular_acls_view_only))
|
||||
.route("/add/{*path}", post(add_granular_acl))
|
||||
.route("/remove/{*path}", post(remove_granular_acl))
|
||||
}
|
||||
@@ -102,8 +101,8 @@ pub enum AclLevel {
|
||||
Write,
|
||||
}
|
||||
|
||||
/// Kinds whose ACL tells reading from running (`view_only`). On every other kind a read grant is
|
||||
/// all there is.
|
||||
/// Kinds whose ACL tells reading from running, with a `"read"` value. On every other kind `false`
|
||||
/// is all a reader gets.
|
||||
const RUN_LEVEL_KINDS: [&str; 4] = ["script", "flow", "resource", "folder"];
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
@@ -212,25 +211,22 @@ async fn add_granular_acl(
|
||||
// DeployedObject::RawApp so the worker writes back `<path>.raw_app.json`.
|
||||
let table = if kind == "raw_app" { "app" } else { kind };
|
||||
// SAFETY: `kind` has been validated against the `KINDS` allowlist before reaching this function.
|
||||
let set_view_only = if has_run_level {
|
||||
", view_only = CASE WHEN $6 THEN array_append(array_remove(view_only, $5), $5) \
|
||||
ELSE array_remove(view_only, $5) END"
|
||||
} else {
|
||||
""
|
||||
// Run and write stay `false` and `true`, which every client reads; only the level they
|
||||
// could not express is a string.
|
||||
let value = match level {
|
||||
AclLevel::Read => serde_json::json!("read"),
|
||||
_ => serde_json::json!(level == AclLevel::Write),
|
||||
};
|
||||
let sql = format!(
|
||||
"UPDATE {table} SET extra_perms = jsonb_set(extra_perms, $1, to_jsonb($2), \
|
||||
true){set_view_only} WHERE {identifier} = $3 AND workspace_id = $4 RETURNING extra_perms"
|
||||
);
|
||||
let mut query = sqlx::query_scalar::<_, serde_json::Value>(&sql)
|
||||
.bind(vec![owner.clone()])
|
||||
.bind(write.unwrap_or(false))
|
||||
.bind(path)
|
||||
.bind(&w_id);
|
||||
if has_run_level {
|
||||
query = query.bind(&owner).bind(level == AclLevel::Read);
|
||||
}
|
||||
let obj_o = query.fetch_optional(&mut *tx).await?;
|
||||
let obj_o = sqlx::query_scalar::<_, serde_json::Value>(&format!(
|
||||
"UPDATE {table} SET extra_perms = jsonb_set(extra_perms, $1, $2, \
|
||||
true) WHERE {identifier} = $3 AND workspace_id = $4 RETURNING extra_perms"
|
||||
))
|
||||
.bind(vec![owner.clone()])
|
||||
.bind(value)
|
||||
.bind(path)
|
||||
.bind(&w_id)
|
||||
.fetch_optional(&mut *tx)
|
||||
.await?;
|
||||
|
||||
let _ = not_found_if_none(obj_o, &kind, &path)?;
|
||||
|
||||
@@ -465,19 +461,14 @@ async fn remove_granular_acl(
|
||||
// LIMIT 1: `script` shares (workspace_id, path) across versions, so `old` can
|
||||
// return >1 row, which would break the scalar subquery in RETURNING.
|
||||
let has_run_level = RUN_LEVEL_KINDS.contains(&kind);
|
||||
let unset_view_only = if has_run_level {
|
||||
", view_only = array_remove(view_only, $1)"
|
||||
} else {
|
||||
""
|
||||
};
|
||||
let obj_o = sqlx::query_scalar::<_, bool>(&format!(
|
||||
"WITH old AS (
|
||||
SELECT extra_perms->$1 as old_write FROM {table}
|
||||
WHERE {identifier} = $2 AND workspace_id = $3 AND extra_perms ? $1
|
||||
)
|
||||
UPDATE {table} SET extra_perms = extra_perms - $1{unset_view_only}
|
||||
UPDATE {table} SET extra_perms = extra_perms - $1
|
||||
WHERE {identifier} = $2 AND workspace_id = $3 AND extra_perms ? $1
|
||||
RETURNING (SELECT old_write FROM old LIMIT 1)::bool"
|
||||
RETURNING (SELECT old_write FROM old LIMIT 1) IN ('true', '\"write\"')"
|
||||
))
|
||||
.bind(&owner)
|
||||
.bind(path)
|
||||
@@ -676,34 +667,3 @@ async fn get_granular_acls(
|
||||
|
||||
Ok(Json(obj))
|
||||
}
|
||||
|
||||
/// The principals of `/acls/get` whose read grant does not include running: empty for every kind
|
||||
/// without a run level.
|
||||
async fn get_granular_acls_view_only(
|
||||
authed: ApiAuthed,
|
||||
Extension(user_db): Extension<UserDB>,
|
||||
Path((w_id, path)): Path<(String, StripPath)>,
|
||||
) -> JsonResult<Vec<String>> {
|
||||
let path = path.to_path();
|
||||
let (kind, path) = path
|
||||
.split_once('/')
|
||||
.ok_or_else(|| Error::BadRequest("Invalid path or kind".to_string()))?;
|
||||
if !KINDS.contains(&kind) {
|
||||
return Err(Error::BadRequest("Invalid kind".to_string()));
|
||||
}
|
||||
if !RUN_LEVEL_KINDS.contains(&kind) {
|
||||
return Ok(Json(vec![]));
|
||||
}
|
||||
let identifier = if kind == "folder" { "name" } else { "path" };
|
||||
let mut tx = user_db.begin(&authed).await?;
|
||||
// SAFETY: `kind` is one of `RUN_LEVEL_KINDS`.
|
||||
let view_only = sqlx::query_scalar::<_, Vec<String>>(&format!(
|
||||
"SELECT view_only FROM {kind} WHERE {identifier} = $1 AND workspace_id = $2 LIMIT 1"
|
||||
))
|
||||
.bind(path)
|
||||
.bind(w_id)
|
||||
.fetch_optional(&mut *tx)
|
||||
.await?;
|
||||
tx.commit().await?;
|
||||
Ok(Json(not_found_if_none(view_only, &kind, &path)?))
|
||||
}
|
||||
|
||||
@@ -47,6 +47,12 @@ async fn test_view_only_grants(db: Pool<Postgres>) -> anyhow::Result<()> {
|
||||
let admin = client_for("SECRET_TOKEN");
|
||||
let viewer = client_for("SECRET_TOKEN_2"); // test-user-2
|
||||
let runner = client_for("SECRET_TOKEN_3"); // test-user-3
|
||||
// Before any request of theirs: the groups of a token are cached.
|
||||
sqlx::query(
|
||||
"INSERT INTO usr_to_group (workspace_id, group_, usr) VALUES ('test-workspace', 'all', 'test-user-2')",
|
||||
)
|
||||
.execute(&db)
|
||||
.await?;
|
||||
|
||||
assert_eq!(
|
||||
post(&admin, port, "folders/create", json!({"name": "vo"})).await?,
|
||||
@@ -238,6 +244,27 @@ async fn test_view_only_grants(db: Pool<Postgres>) -> anyhow::Result<()> {
|
||||
post(&runner, port, "jobs/run/p/u/test-user/own", json!({})).await?,
|
||||
403
|
||||
);
|
||||
// A personal view-only grant beside a group's write grant: the write policies read it
|
||||
// without failing on it.
|
||||
for grant in [
|
||||
json!({"owner": "g/all", "write": true}),
|
||||
json!({"owner": "u/test-user-2", "level": "read"}),
|
||||
] {
|
||||
assert_eq!(
|
||||
post(&admin, port, "acls/add/script/u/test-user/own", grant).await?,
|
||||
200
|
||||
);
|
||||
}
|
||||
let deployed: serde_json::Value = admin
|
||||
.get(format!(
|
||||
"http://localhost:{port}/api/w/{WS}/scripts/get/p/u/test-user/own"
|
||||
))
|
||||
.send()
|
||||
.await?
|
||||
.json()
|
||||
.await?;
|
||||
let next = bash_script("u/test-user/own", deployed["hash"].as_str());
|
||||
assert_eq!(post(&viewer, port, "scripts/create", next).await?, 201);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -203,7 +203,6 @@ async fn list_scripts(
|
||||
"o.created_at as created_at",
|
||||
"archived",
|
||||
"extra_perms",
|
||||
"o.view_only",
|
||||
if !lq.without_description.unwrap_or(false) {
|
||||
"description"
|
||||
} else {
|
||||
@@ -455,7 +454,6 @@ async fn list_scripts(
|
||||
created_at: row.created_at,
|
||||
archived: false,
|
||||
extra_perms: serde_json::Value::Object(serde_json::Map::new()),
|
||||
view_only: vec![],
|
||||
language,
|
||||
starred: false,
|
||||
tag: v.get("tag").and_then(|s| s.as_str()).map(|s| s.to_string()),
|
||||
@@ -1546,7 +1544,6 @@ async fn create_script_internal<'c>(
|
||||
struct ParentInfo {
|
||||
p_hashes: Vec<i64>,
|
||||
perms: serde_json::Value,
|
||||
view_only: Vec<String>,
|
||||
p_path: String,
|
||||
}
|
||||
// When auto_parent is set, resolve parent_hash to the current head for this path
|
||||
@@ -1829,11 +1826,6 @@ async fn create_script_internal<'c>(
|
||||
} else {
|
||||
ps.extra_perms
|
||||
},
|
||||
view_only: if parent_adopted_from_retired_path {
|
||||
vec![]
|
||||
} else {
|
||||
ps.view_only
|
||||
},
|
||||
p_path: ps.path,
|
||||
})),
|
||||
};
|
||||
@@ -1853,10 +1845,6 @@ async fn create_script_internal<'c>(
|
||||
.as_ref()
|
||||
.map(|v| v.perms.clone())
|
||||
.unwrap_or(json!({}));
|
||||
let view_only = parent_hashes_and_perms
|
||||
.as_ref()
|
||||
.map(|v| v.view_only.clone())
|
||||
.unwrap_or_default();
|
||||
// A dbt lock names a manifest digest and engine versions that only a
|
||||
// dependency job can determine, and that job is also what publishes the
|
||||
// script's manifest graph. Honouring a supplied one would skip it, leaving
|
||||
@@ -2397,16 +2385,6 @@ async fn create_script_internal<'c>(
|
||||
)
|
||||
.execute(&mut *tx)
|
||||
.await?;
|
||||
if !view_only.is_empty() {
|
||||
sqlx::query!(
|
||||
"UPDATE script SET view_only = $1 WHERE hash = $2 AND workspace_id = $3",
|
||||
&view_only,
|
||||
&hash.0,
|
||||
&w_id
|
||||
)
|
||||
.execute(&mut *tx)
|
||||
.await?;
|
||||
}
|
||||
windmill_common::scopes::log_job_token_scopes_deploy(
|
||||
"script",
|
||||
resolved_job_token_scopes.as_deref(),
|
||||
|
||||
@@ -2612,14 +2612,8 @@ pub async fn delete_workspace_user_internal(
|
||||
];
|
||||
// SAFETY: `table` comes from a hardcoded allowlist `extra_perms_tables`, not user input.
|
||||
for table in &extra_perms_tables {
|
||||
// A `view_only` entry left behind would make a later grant to a re-added user view-only.
|
||||
let view_only = if ["script", "flow", "resource", "folder"].contains(table) {
|
||||
", view_only = array_remove(view_only, 'u/' || $1)"
|
||||
} else {
|
||||
""
|
||||
};
|
||||
sqlx::query(&format!(
|
||||
"UPDATE {table} SET extra_perms = extra_perms - ('u/' || $1){view_only} \
|
||||
"UPDATE {table} SET extra_perms = extra_perms - ('u/' || $1) \
|
||||
WHERE extra_perms ? ('u/' || $1) AND workspace_id = $2"
|
||||
))
|
||||
.bind(username_to_delete)
|
||||
|
||||
@@ -8066,8 +8066,8 @@ async fn clone_folders(
|
||||
target_workspace_id: &str,
|
||||
) -> Result<()> {
|
||||
sqlx::query!(
|
||||
"INSERT INTO folder (workspace_id, name, display_name, owners, extra_perms, view_only, summary, edited_at, created_by, default_permissioned_as, labels)
|
||||
SELECT $2, name, display_name, owners, extra_perms, view_only, summary, edited_at, created_by, default_permissioned_as, labels
|
||||
"INSERT INTO folder (workspace_id, name, display_name, owners, extra_perms, summary, edited_at, created_by, default_permissioned_as, labels)
|
||||
SELECT $2, name, display_name, owners, extra_perms, summary, edited_at, created_by, default_permissioned_as, labels
|
||||
FROM folder
|
||||
WHERE workspace_id = $1",
|
||||
source_workspace_id,
|
||||
@@ -8248,13 +8248,13 @@ async fn clone_resources(
|
||||
let repoint = (!windmill_common::can_preserve_on_behalf_of(authed))
|
||||
.then(|| username_to_permissioned_as(&authed.username));
|
||||
sqlx::query!(
|
||||
"INSERT INTO resource (workspace_id, path, value, description, resource_type, extra_perms, view_only, edited_at, created_by)
|
||||
"INSERT INTO resource (workspace_id, path, value, description, resource_type, extra_perms, edited_at, created_by)
|
||||
SELECT $2, path,
|
||||
CASE WHEN $3::text IS NOT NULL AND resource_type = 'ai_agent'
|
||||
AND jsonb_typeof(value) = 'object' AND value ? 'on_behalf_of'
|
||||
THEN jsonb_set(value, '{on_behalf_of}', to_jsonb($3::text))
|
||||
ELSE value END,
|
||||
description, resource_type, extra_perms, view_only, edited_at, created_by
|
||||
description, resource_type, extra_perms, edited_at, created_by
|
||||
FROM resource
|
||||
WHERE workspace_id = $1",
|
||||
source_workspace_id,
|
||||
@@ -8384,7 +8384,7 @@ async fn clone_scripts(
|
||||
r#"INSERT INTO script (
|
||||
workspace_id, hash, path, parent_hashes, summary, description, content,
|
||||
created_by, created_at, archived, schema, deleted, is_template,
|
||||
extra_perms, view_only, lock, lock_error_logs, language, kind, tag,
|
||||
extra_perms, lock, lock_error_logs, language, kind, tag,
|
||||
envs, concurrent_limit, concurrency_time_window_s, cache_ttl,
|
||||
dedicated_worker, ws_error_handler_muted, priority, timeout,
|
||||
delete_after_use, delete_after_secs, restart_unless_cancelled, concurrency_key,
|
||||
@@ -8394,7 +8394,7 @@ async fn clone_scripts(
|
||||
SELECT
|
||||
$1, hash, path, parent_hashes, summary, description, content,
|
||||
created_by, created_at, archived, schema, deleted, is_template,
|
||||
extra_perms, view_only, lock, lock_error_logs, language, kind, tag,
|
||||
extra_perms, lock, lock_error_logs, language, kind, tag,
|
||||
envs, concurrent_limit, concurrency_time_window_s, cache_ttl,
|
||||
dedicated_worker, ws_error_handler_muted, priority, timeout,
|
||||
delete_after_use, delete_after_secs, restart_unless_cancelled, concurrency_key,
|
||||
@@ -8821,13 +8821,13 @@ async fn clone_flows(
|
||||
sqlx::query!(
|
||||
"INSERT INTO flow (
|
||||
workspace_id, path, summary, description, value, edited_by, edited_at,
|
||||
archived, schema, extra_perms, view_only, dependency_job, tag,
|
||||
archived, schema, extra_perms, dependency_job, tag,
|
||||
ws_error_handler_muted, dedicated_worker, timeout, visible_to_runner_only,
|
||||
concurrency_key, versions, on_behalf_of, on_behalf_of_email, lock_error_logs,
|
||||
job_token_scopes
|
||||
)
|
||||
SELECT $2, path, summary, description, value, edited_by, edited_at,
|
||||
archived, schema, extra_perms, view_only, NULL, tag,
|
||||
archived, schema, extra_perms, NULL, tag,
|
||||
ws_error_handler_muted, dedicated_worker, timeout, visible_to_runner_only,
|
||||
concurrency_key, ARRAY[]::bigint[],
|
||||
-- Same predicate as clone_scripts.
|
||||
|
||||
@@ -450,8 +450,8 @@ pub(crate) async fn change_workspace_id(
|
||||
info!("Duplicating flow table rows");
|
||||
sqlx::query!(
|
||||
"INSERT INTO flow
|
||||
(workspace_id, path, summary, description, archived, extra_perms, view_only, dependency_job, tag, ws_error_handler_muted, dedicated_worker, timeout, visible_to_runner_only, on_behalf_of, on_behalf_of_email, concurrency_key, versions, value, schema, edited_by, edited_at, lock_error_logs, job_token_scopes)
|
||||
SELECT $1, path, summary, description, archived, extra_perms, view_only, dependency_job, tag, ws_error_handler_muted, dedicated_worker, timeout, visible_to_runner_only, on_behalf_of, on_behalf_of_email, concurrency_key, versions, value, schema, edited_by, edited_at, lock_error_logs, job_token_scopes
|
||||
(workspace_id, path, summary, description, archived, extra_perms, dependency_job, tag, ws_error_handler_muted, dedicated_worker, timeout, visible_to_runner_only, on_behalf_of, on_behalf_of_email, concurrency_key, versions, value, schema, edited_by, edited_at, lock_error_logs, job_token_scopes)
|
||||
SELECT $1, path, summary, description, archived, extra_perms, dependency_job, tag, ws_error_handler_muted, dedicated_worker, timeout, visible_to_runner_only, on_behalf_of, on_behalf_of_email, concurrency_key, versions, value, schema, edited_by, edited_at, lock_error_logs, job_token_scopes
|
||||
FROM flow WHERE workspace_id = $2",
|
||||
&rw.new_id,
|
||||
&old_id
|
||||
@@ -696,8 +696,8 @@ pub(crate) async fn change_workspace_id(
|
||||
// Duplicate folders with new workspace id (FK constraint)
|
||||
info!("Duplicating folder table rows");
|
||||
sqlx::query!(
|
||||
"INSERT INTO folder (name, workspace_id, display_name, owners, extra_perms, view_only, summary, edited_at, created_by, default_permissioned_as, labels) \
|
||||
SELECT name, $1, display_name, owners, extra_perms, view_only, summary, edited_at, created_by, default_permissioned_as, labels \
|
||||
"INSERT INTO folder (name, workspace_id, display_name, owners, extra_perms, summary, edited_at, created_by, default_permissioned_as, labels) \
|
||||
SELECT name, $1, display_name, owners, extra_perms, summary, edited_at, created_by, default_permissioned_as, labels \
|
||||
FROM folder WHERE workspace_id = $2",
|
||||
&rw.new_id,
|
||||
&old_id
|
||||
|
||||
@@ -24685,12 +24685,7 @@ paths:
|
||||
type: string
|
||||
extra_perms:
|
||||
additionalProperties:
|
||||
type: boolean
|
||||
view_only:
|
||||
type: array
|
||||
description: Principals of `extra_perms` that may view what the folder holds but not run it.
|
||||
items:
|
||||
type: string
|
||||
$ref: "#/components/schemas/AclValue"
|
||||
default_permissioned_as:
|
||||
$ref: '#/components/schemas/FolderDefaultPermissionedAs'
|
||||
labels:
|
||||
@@ -24734,12 +24729,7 @@ paths:
|
||||
type: string
|
||||
extra_perms:
|
||||
additionalProperties:
|
||||
type: boolean
|
||||
view_only:
|
||||
type: array
|
||||
description: Principals of `extra_perms` that may view what the folder holds but not run it. Omitted keeps the stored list.
|
||||
items:
|
||||
type: string
|
||||
$ref: "#/components/schemas/AclValue"
|
||||
default_permissioned_as:
|
||||
$ref: '#/components/schemas/FolderDefaultPermissionedAs'
|
||||
labels:
|
||||
@@ -25697,34 +25687,7 @@ paths:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
additionalProperties:
|
||||
type: boolean
|
||||
|
||||
/w/{workspace}/acls/get_view_only/{kind}/{path}:
|
||||
get:
|
||||
summary: get the principals of the granular acls that may view but not run
|
||||
operationId: getGranularAclsViewOnly
|
||||
tags:
|
||||
- granular_acl
|
||||
parameters:
|
||||
- $ref: "#/components/parameters/WorkspaceId"
|
||||
- $ref: "#/components/parameters/Path"
|
||||
- name: kind
|
||||
in: path
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
enum: [script, flow, resource, folder]
|
||||
responses:
|
||||
"200":
|
||||
description: principals with a view-only grant
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
$ref: "#/components/schemas/ExtraPerms"
|
||||
|
||||
/w/{workspace}/acls/add/{kind}/{path}:
|
||||
post:
|
||||
@@ -31985,7 +31948,7 @@ components:
|
||||
extra_perms:
|
||||
type: object
|
||||
additionalProperties:
|
||||
type: boolean
|
||||
$ref: "#/components/schemas/AclValue"
|
||||
starred:
|
||||
type: boolean
|
||||
archived:
|
||||
@@ -32089,12 +32052,7 @@ components:
|
||||
extra_perms:
|
||||
type: object
|
||||
additionalProperties:
|
||||
type: boolean
|
||||
view_only:
|
||||
type: array
|
||||
description: Principals of `extra_perms` that may view but not run it.
|
||||
items:
|
||||
type: string
|
||||
$ref: "#/components/schemas/AclValue"
|
||||
lock:
|
||||
type: string
|
||||
lock_error_logs:
|
||||
@@ -33542,7 +33500,7 @@ components:
|
||||
extra_perms:
|
||||
type: object
|
||||
additionalProperties:
|
||||
type: boolean
|
||||
$ref: "#/components/schemas/AclValue"
|
||||
is_expired:
|
||||
type: boolean
|
||||
refresh_error:
|
||||
@@ -34211,12 +34169,7 @@ components:
|
||||
extra_perms:
|
||||
type: object
|
||||
additionalProperties:
|
||||
type: boolean
|
||||
view_only:
|
||||
type: array
|
||||
description: Principals of `extra_perms` that may view but not run it.
|
||||
items:
|
||||
type: string
|
||||
$ref: "#/components/schemas/AclValue"
|
||||
created_by:
|
||||
type: string
|
||||
edited_at:
|
||||
@@ -34278,12 +34231,7 @@ components:
|
||||
extra_perms:
|
||||
type: object
|
||||
additionalProperties:
|
||||
type: boolean
|
||||
view_only:
|
||||
type: array
|
||||
description: Principals of `extra_perms` that may view but not run it.
|
||||
items:
|
||||
type: string
|
||||
$ref: "#/components/schemas/AclValue"
|
||||
is_expired:
|
||||
type: boolean
|
||||
refresh_error:
|
||||
@@ -34472,7 +34420,7 @@ components:
|
||||
extra_perms:
|
||||
type: object
|
||||
additionalProperties:
|
||||
type: boolean
|
||||
$ref: "#/components/schemas/AclValue"
|
||||
description: Additional permissions for this schedule
|
||||
email:
|
||||
type: string
|
||||
@@ -34882,7 +34830,7 @@ components:
|
||||
type: object
|
||||
description: Additional permissions for this trigger
|
||||
additionalProperties:
|
||||
type: boolean
|
||||
$ref: "#/components/schemas/AclValue"
|
||||
workspace_id:
|
||||
type: string
|
||||
description: The workspace this trigger belongs to
|
||||
@@ -37883,7 +37831,7 @@ components:
|
||||
extra_perms:
|
||||
type: object
|
||||
additionalProperties:
|
||||
type: boolean
|
||||
$ref: "#/components/schemas/AclValue"
|
||||
required:
|
||||
- name
|
||||
|
||||
@@ -37971,12 +37919,7 @@ components:
|
||||
extra_perms:
|
||||
type: object
|
||||
additionalProperties:
|
||||
type: boolean
|
||||
view_only:
|
||||
type: array
|
||||
description: Principals of `extra_perms` that may view but not run it.
|
||||
items:
|
||||
type: string
|
||||
$ref: "#/components/schemas/AclValue"
|
||||
summary:
|
||||
type: string
|
||||
created_by:
|
||||
@@ -38482,7 +38425,17 @@ components:
|
||||
ExtraPerms:
|
||||
type: object
|
||||
additionalProperties:
|
||||
type: boolean
|
||||
$ref: "#/components/schemas/AclValue"
|
||||
|
||||
AclValue:
|
||||
description: >
|
||||
A grant: `true` writes; `false` is the level below write, which runs a script, flow or
|
||||
AI agent and reads anything else; or the level by name. `read` alone views a script,
|
||||
flow, AI agent or folder content without running it.
|
||||
oneOf:
|
||||
- type: boolean
|
||||
- type: string
|
||||
enum: [read, run, write]
|
||||
|
||||
FlowMetadata:
|
||||
type: object
|
||||
@@ -38500,11 +38453,6 @@ components:
|
||||
type: boolean
|
||||
extra_perms:
|
||||
$ref: "#/components/schemas/ExtraPerms"
|
||||
view_only:
|
||||
type: array
|
||||
description: Principals of `extra_perms` that may view but not run it.
|
||||
items:
|
||||
type: string
|
||||
starred:
|
||||
type: boolean
|
||||
draft_only:
|
||||
@@ -38769,7 +38717,7 @@ components:
|
||||
extra_perms:
|
||||
type: object
|
||||
additionalProperties:
|
||||
type: boolean
|
||||
$ref: "#/components/schemas/AclValue"
|
||||
starred:
|
||||
type: boolean
|
||||
edited_at:
|
||||
@@ -38879,7 +38827,7 @@ components:
|
||||
extra_perms:
|
||||
type: object
|
||||
additionalProperties:
|
||||
type: boolean
|
||||
$ref: "#/components/schemas/AclValue"
|
||||
starred:
|
||||
type: boolean
|
||||
version:
|
||||
@@ -38937,7 +38885,7 @@ components:
|
||||
extra_perms:
|
||||
type: object
|
||||
additionalProperties:
|
||||
type: boolean
|
||||
$ref: "#/components/schemas/AclValue"
|
||||
custom_path:
|
||||
type: string
|
||||
raw_app:
|
||||
|
||||
@@ -502,7 +502,7 @@
|
||||
},
|
||||
{
|
||||
"name": "read_workspace_item",
|
||||
"description": "Read one workspace item or draft. Prefers your draft when one exists; pass version: \"deployed\" to read the deployed state instead. A deployed item carries extraPerms (a draft does not; pass version: \"deployed\" for it): who it is shared with beyond its owner, as u/<user> or g/<group> → true (write) or false (read-only). A folder returns its owners and extraPerms; a group returns its members and extraPerms (who may manage it). For a folder or group, path is its name. A g/<group> entry grants every member of that group (g/all is everyone), and workspace admins can read and write every folder and item whatever these lists say.",
|
||||
"description": "Read one workspace item or draft. Prefers your draft when one exists; pass version: \"deployed\" to read the deployed state instead. A deployed item carries extraPerms (a draft does not; pass version: \"deployed\" for it): who it is shared with beyond its owner, as u/<user> or g/<group> → true (write), false (read; on a script, flow, agent or folder also run) or \"read\" (view only: sees it and its runs, cannot run it). A folder returns its owners and extraPerms; a group returns its members and extraPerms (who may manage it). For a folder or group, path is its name. A g/<group> entry grants every member of that group (g/all is everyone), and workspace admins can read and write every folder and item whatever these lists say.",
|
||||
"parameters": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
||||
@@ -2414,7 +2414,6 @@ async fn require_preview_label_runnable(
|
||||
/// A job, or one of its `parent_job` ancestors, as its ACL names what it runs.
|
||||
struct JobRunnable {
|
||||
id: Uuid,
|
||||
depth: i32,
|
||||
created_by: String,
|
||||
target: Option<(RunnableAclKind, String)>,
|
||||
}
|
||||
@@ -2434,7 +2433,7 @@ async fn job_runnables(db: &DB, w_id: &str, ids: &[Uuid]) -> error::Result<Vec<J
|
||||
JOIN chain c ON j.id = c.parent_job AND j.workspace_id = $2
|
||||
WHERE c.depth < 100
|
||||
)
|
||||
SELECT c.origin AS "id!", c.depth AS "depth!", j.created_by AS "created_by!",
|
||||
SELECT c.origin AS "id!", j.created_by AS "created_by!",
|
||||
CASE WHEN a.agent THEN regexp_replace(j.runnable_path, '\.chat$', '')
|
||||
ELSE j.runnable_path END AS runnable_path,
|
||||
CASE
|
||||
@@ -2470,17 +2469,13 @@ async fn job_runnables(db: &DB, w_id: &str, ids: &[Uuid]) -> error::Result<Vec<J
|
||||
Some("flow") => Some(RunnableAclKind::Flow),
|
||||
_ => None,
|
||||
};
|
||||
JobRunnable {
|
||||
id: r.id,
|
||||
depth: r.depth,
|
||||
created_by: r.created_by,
|
||||
target: kind.zip(r.runnable_path),
|
||||
}
|
||||
JobRunnable { id: r.id, created_by: r.created_by, target: kind.zip(r.runnable_path) }
|
||||
})
|
||||
.collect())
|
||||
}
|
||||
|
||||
/// `require_can_run` on what the job itself runs, for a route that starts it again.
|
||||
/// `require_can_run` on what the job runs, for a route that starts it again: its own runnable,
|
||||
/// or for a branch or loop child, which has none, the nearest ancestor's.
|
||||
#[cfg(feature = "enterprise")]
|
||||
async fn require_can_run_job(
|
||||
db: &DB,
|
||||
@@ -2488,10 +2483,12 @@ async fn require_can_run_job(
|
||||
w_id: &str,
|
||||
id: Uuid,
|
||||
) -> error::Result<()> {
|
||||
for job in job_runnables(db, w_id, &[id]).await? {
|
||||
if let (0, Some((kind, path))) = (job.depth, job.target) {
|
||||
require_can_run(db, &authed.to_authed_ref(), w_id, kind, &path).await?;
|
||||
}
|
||||
let nearest = job_runnables(db, w_id, &[id])
|
||||
.await?
|
||||
.into_iter()
|
||||
.find_map(|job| job.target);
|
||||
if let Some((kind, path)) = nearest {
|
||||
require_can_run(db, &authed.to_authed_ref(), w_id, kind, &path).await?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -197,10 +197,10 @@ fn items_query(
|
||||
sqlb.and_where(format!(
|
||||
"(split_part(o.path, '/', 1) = 'u' AND split_part(o.path, '/', 2) = current_setting('session.user') \
|
||||
OR split_part(o.path, '/', 1) = 'g' AND split_part(o.path, '/', 2) = ANY(regexp_split_to_array(current_setting('session.groups'), ',')) \
|
||||
OR acl_grants_run(o.extra_perms, o.view_only, {principals}) \
|
||||
OR acl_grants_run(o.extra_perms, {principals}) \
|
||||
OR EXISTS (SELECT 1 FROM folder f WHERE split_part(o.path, '/', 1) = 'f' \
|
||||
AND f.workspace_id = o.workspace_id AND f.name = split_part(o.path, '/', 2) \
|
||||
AND (f.owners::text[] && {principals} OR acl_grants_run(f.extra_perms, f.view_only, {principals}))))"
|
||||
AND (f.owners::text[] && {principals} OR acl_grants_run(f.extra_perms, {principals}))))"
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
@@ -894,8 +894,8 @@ async fn offboard_user_from_workspace<'c>(
|
||||
let flows_reassigned = sqlx::query_scalar!(
|
||||
r#"WITH inserted AS (
|
||||
INSERT INTO flow
|
||||
(workspace_id, path, summary, description, archived, extra_perms, view_only, dependency_job, tag, ws_error_handler_muted, dedicated_worker, timeout, visible_to_runner_only, on_behalf_of, on_behalf_of_email, concurrency_key, versions, value, schema, edited_by, edited_at, labels, lock_error_logs, job_token_scopes)
|
||||
SELECT workspace_id, REGEXP_REPLACE(path, 'u/' || $2 || '/(.*)', $1 || '/\1'), summary, description, archived, extra_perms, view_only, dependency_job, tag, ws_error_handler_muted, dedicated_worker, timeout, visible_to_runner_only, on_behalf_of, on_behalf_of_email, concurrency_key, versions, value, schema, edited_by, edited_at, labels, lock_error_logs, job_token_scopes
|
||||
(workspace_id, path, summary, description, archived, extra_perms, dependency_job, tag, ws_error_handler_muted, dedicated_worker, timeout, visible_to_runner_only, on_behalf_of, on_behalf_of_email, concurrency_key, versions, value, schema, edited_by, edited_at, labels, lock_error_logs, job_token_scopes)
|
||||
SELECT workspace_id, REGEXP_REPLACE(path, 'u/' || $2 || '/(.*)', $1 || '/\1'), summary, description, archived, extra_perms, dependency_job, tag, ws_error_handler_muted, dedicated_worker, timeout, visible_to_runner_only, on_behalf_of, on_behalf_of_email, concurrency_key, versions, value, schema, edited_by, edited_at, labels, lock_error_logs, job_token_scopes
|
||||
FROM flow
|
||||
WHERE path LIKE ('u/' || $2 || '/%') AND workspace_id = $3
|
||||
RETURNING 1
|
||||
|
||||
@@ -206,10 +206,8 @@ async fn restore_script(tx: &mut sqlx::PgConnection, item: &TrashItemWithData) -
|
||||
.and_then(|v| v.as_array())
|
||||
.ok_or_else(|| Error::internal_err("Invalid trash data for script"))?;
|
||||
|
||||
// The `view_only` default merged under each snapshot of a script, flow or resource: one
|
||||
// trashed before the column existed lacks the key, which would insert NULL into it.
|
||||
for script in scripts {
|
||||
sqlx::query("INSERT INTO script SELECT * FROM jsonb_populate_record(null::script, '{\"view_only\": []}'::jsonb || $1)")
|
||||
sqlx::query("INSERT INTO script SELECT * FROM jsonb_populate_record(null::script, $1)")
|
||||
.bind(script)
|
||||
.execute(&mut *tx)
|
||||
.await
|
||||
@@ -255,7 +253,7 @@ async fn restore_flow(tx: &mut sqlx::PgConnection, item: &TrashItemWithData) ->
|
||||
.get("row")
|
||||
.ok_or_else(|| Error::internal_err("Invalid trash data for flow"))?;
|
||||
|
||||
sqlx::query("INSERT INTO flow SELECT * FROM jsonb_populate_record(null::flow, '{\"view_only\": []}'::jsonb || $1)")
|
||||
sqlx::query("INSERT INTO flow SELECT * FROM jsonb_populate_record(null::flow, $1)")
|
||||
.bind(row)
|
||||
.execute(&mut *tx)
|
||||
.await?;
|
||||
@@ -427,7 +425,7 @@ async fn restore_variable(tx: &mut sqlx::PgConnection, item: &TrashItemWithData)
|
||||
if let Some(linked_resource) = data.get("linked_resource") {
|
||||
if !linked_resource.is_null() {
|
||||
sqlx::query(
|
||||
"INSERT INTO resource SELECT * FROM jsonb_populate_record(null::resource, '{\"view_only\": []}'::jsonb || $1)
|
||||
"INSERT INTO resource SELECT * FROM jsonb_populate_record(null::resource, $1)
|
||||
ON CONFLICT DO NOTHING",
|
||||
)
|
||||
.bind(linked_resource)
|
||||
@@ -462,7 +460,7 @@ async fn restore_resource(tx: &mut sqlx::PgConnection, item: &TrashItemWithData)
|
||||
.get("row")
|
||||
.ok_or_else(|| Error::internal_err("Invalid trash data for resource"))?;
|
||||
|
||||
sqlx::query("INSERT INTO resource SELECT * FROM jsonb_populate_record(null::resource, '{\"view_only\": []}'::jsonb || $1)")
|
||||
sqlx::query("INSERT INTO resource SELECT * FROM jsonb_populate_record(null::resource, $1)")
|
||||
.bind(row)
|
||||
.execute(&mut *tx)
|
||||
.await?;
|
||||
|
||||
@@ -596,7 +596,7 @@ async fn update_username_in_workpsace<'c>(
|
||||
.await?;
|
||||
|
||||
sqlx::query!(
|
||||
"UPDATE resource SET extra_perms = extra_perms - ('u/' || $2) || jsonb_build_object(('u/' || $1), extra_perms->('u/' || $2)), view_only = array_replace(view_only, 'u/' || $2, 'u/' || $1) WHERE extra_perms ? ('u/' || $2) AND workspace_id = $3",
|
||||
"UPDATE resource SET extra_perms = extra_perms - ('u/' || $2) || jsonb_build_object(('u/' || $1), extra_perms->('u/' || $2)) WHERE extra_perms ? ('u/' || $2) AND workspace_id = $3",
|
||||
new_username,
|
||||
old_username,
|
||||
w_id
|
||||
@@ -781,7 +781,7 @@ async fn update_username_in_workpsace<'c>(
|
||||
.unwrap();
|
||||
|
||||
sqlx::query!(
|
||||
"UPDATE script SET extra_perms = extra_perms - ('u/' || $2) || jsonb_build_object(('u/' || $1), extra_perms->('u/' || $2)), view_only = array_replace(view_only, 'u/' || $2, 'u/' || $1) WHERE extra_perms ? ('u/' || $2) AND workspace_id = $3",
|
||||
"UPDATE script SET extra_perms = extra_perms - ('u/' || $2) || jsonb_build_object(('u/' || $1), extra_perms->('u/' || $2)) WHERE extra_perms ? ('u/' || $2) AND workspace_id = $3",
|
||||
new_username,
|
||||
old_username,
|
||||
w_id
|
||||
@@ -806,8 +806,8 @@ async fn update_username_in_workpsace<'c>(
|
||||
// ---- flows ----
|
||||
sqlx::query!(
|
||||
r#"INSERT INTO flow
|
||||
(workspace_id, path, summary, description, archived, extra_perms, view_only, dependency_job, tag, ws_error_handler_muted, dedicated_worker, timeout, visible_to_runner_only, on_behalf_of, on_behalf_of_email, concurrency_key, versions, value, schema, edited_by, edited_at, job_token_scopes)
|
||||
SELECT workspace_id, REGEXP_REPLACE(path,'u/' || $2 || '/(.*)','u/' || $1 || '/\1'), summary, description, archived, extra_perms, view_only, dependency_job, tag, ws_error_handler_muted, dedicated_worker, timeout, visible_to_runner_only, on_behalf_of, on_behalf_of_email, concurrency_key, versions, value, schema, edited_by, edited_at, job_token_scopes
|
||||
(workspace_id, path, summary, description, archived, extra_perms, dependency_job, tag, ws_error_handler_muted, dedicated_worker, timeout, visible_to_runner_only, on_behalf_of, on_behalf_of_email, concurrency_key, versions, value, schema, edited_by, edited_at, job_token_scopes)
|
||||
SELECT workspace_id, REGEXP_REPLACE(path,'u/' || $2 || '/(.*)','u/' || $1 || '/\1'), summary, description, archived, extra_perms, dependency_job, tag, ws_error_handler_muted, dedicated_worker, timeout, visible_to_runner_only, on_behalf_of, on_behalf_of_email, concurrency_key, versions, value, schema, edited_by, edited_at, job_token_scopes
|
||||
FROM flow
|
||||
WHERE path LIKE ('u/' || $2 || '/%') AND workspace_id = $3"#,
|
||||
new_username,
|
||||
@@ -876,7 +876,7 @@ async fn update_username_in_workpsace<'c>(
|
||||
.await?;
|
||||
|
||||
sqlx::query!(
|
||||
"UPDATE flow SET extra_perms = extra_perms - ('u/' || $2) || jsonb_build_object(('u/' || $1), extra_perms->('u/' || $2)), view_only = array_replace(view_only, 'u/' || $2, 'u/' || $1) WHERE extra_perms ? ('u/' || $2) AND workspace_id = $3",
|
||||
"UPDATE flow SET extra_perms = extra_perms - ('u/' || $2) || jsonb_build_object(('u/' || $1), extra_perms->('u/' || $2)) WHERE extra_perms ? ('u/' || $2) AND workspace_id = $3",
|
||||
new_username,
|
||||
old_username,
|
||||
w_id
|
||||
@@ -1089,7 +1089,7 @@ async fn update_username_in_workpsace<'c>(
|
||||
.await?;
|
||||
|
||||
sqlx::query!(
|
||||
"UPDATE folder SET extra_perms = extra_perms - ('u/' || $2) || jsonb_build_object(('u/' || $1), extra_perms->('u/' || $2)), view_only = array_replace(view_only, 'u/' || $2, 'u/' || $1) WHERE extra_perms ? ('u/' || $2) AND workspace_id = $3",
|
||||
"UPDATE folder SET extra_perms = extra_perms - ('u/' || $2) || jsonb_build_object(('u/' || $1), extra_perms->('u/' || $2)) WHERE extra_perms ? ('u/' || $2) AND workspace_id = $3",
|
||||
new_username,
|
||||
old_username,
|
||||
w_id
|
||||
|
||||
@@ -123,8 +123,6 @@ struct ScriptMetadata {
|
||||
pub job_token_scopes: Option<Vec<String>>,
|
||||
#[serde(skip_serializing_if = "is_empty_extra_perms")]
|
||||
pub extra_perms: serde_json::Value,
|
||||
#[serde(skip_serializing_if = "Vec::is_empty")]
|
||||
pub view_only: Vec<String>,
|
||||
}
|
||||
|
||||
/// `syncBehavior` as the CLI writes it (`"v1"`); anything unparseable is v0, matching
|
||||
@@ -481,16 +479,6 @@ where
|
||||
obj.remove("extra_perms");
|
||||
}
|
||||
}
|
||||
// Only meaningful beside `extra_perms`, and omitted while empty so files exported
|
||||
// before view-only grants existed stay unchanged.
|
||||
if !obj.contains_key("extra_perms")
|
||||
|| obj
|
||||
.get("view_only")
|
||||
.and_then(|v| v.as_array())
|
||||
.is_some_and(|a| a.is_empty())
|
||||
{
|
||||
obj.remove("view_only");
|
||||
}
|
||||
if obj
|
||||
.get("default_permissioned_as")
|
||||
.and_then(|v| v.as_array())
|
||||
@@ -752,7 +740,7 @@ pub(crate) async fn tarball_workspace(
|
||||
.flatten();
|
||||
|
||||
{
|
||||
let folders = sqlx::query_as::<_, Folder>("SELECT name, workspace_id, display_name, owners, extra_perms, view_only, summary, edited_at, created_by, default_permissioned_as, labels FROM folder WHERE workspace_id = $1")
|
||||
let folders = sqlx::query_as::<_, Folder>("SELECT name, workspace_id, display_name, owners, extra_perms, summary, edited_at, created_by, default_permissioned_as, labels FROM folder WHERE workspace_id = $1")
|
||||
.bind(&w_id)
|
||||
.fetch_all(&mut *tx)
|
||||
.await?;
|
||||
@@ -888,11 +876,6 @@ pub(crate) async fn tarball_workspace(
|
||||
} else {
|
||||
serde_json::Value::Null
|
||||
},
|
||||
view_only: if matches!(new_kinds_extra_perms, ExtraPermsBehavior::KeepIfNonEmpty) {
|
||||
script.view_only
|
||||
} else {
|
||||
vec![]
|
||||
},
|
||||
};
|
||||
let metadata_str = serde_json::to_string_pretty(&metadata).unwrap();
|
||||
archive
|
||||
@@ -904,7 +887,7 @@ pub(crate) async fn tarball_workspace(
|
||||
if !skip_resources.unwrap_or(false) {
|
||||
let resources = sqlx::query_as!(
|
||||
Resource,
|
||||
"SELECT workspace_id, path, value, description, resource_type, extra_perms, view_only, created_by, edited_at, labels FROM resource WHERE workspace_id = $1 AND resource_type <> ALL($2)",
|
||||
"SELECT workspace_id, path, value, description, resource_type, extra_perms, created_by, edited_at, labels FROM resource WHERE workspace_id = $1 AND resource_type <> ALL($2)",
|
||||
&w_id,
|
||||
&windmill_store::resources::INTERNAL_RESOURCE_TYPES.map(|t| t.to_string())[..]
|
||||
)
|
||||
@@ -951,7 +934,7 @@ pub(crate) async fn tarball_workspace(
|
||||
|
||||
{
|
||||
let flows = sqlx::query_as::<_, Flow>(
|
||||
"SELECT flow.workspace_id, flow.path, flow.summary, flow.description, flow.archived, flow.extra_perms, flow.view_only, flow.dedicated_worker, flow.tag, flow.ws_error_handler_muted, flow.timeout, flow.visible_to_runner_only, flow.on_behalf_of, flow.labels, flow.job_token_scopes, flow_version.schema, flow_version.value, flow_version.created_at as edited_at, flow_version.created_by as edited_by
|
||||
"SELECT flow.workspace_id, flow.path, flow.summary, flow.description, flow.archived, flow.extra_perms, flow.dedicated_worker, flow.tag, flow.ws_error_handler_muted, flow.timeout, flow.visible_to_runner_only, flow.on_behalf_of, flow.labels, flow.job_token_scopes, flow_version.schema, flow_version.value, flow_version.created_at as edited_at, flow_version.created_by as edited_by
|
||||
FROM flow
|
||||
LEFT JOIN flow_version ON flow_version.id = flow.versions[array_upper(flow.versions, 1)]
|
||||
WHERE flow.workspace_id = $1 AND flow.archived = false",
|
||||
|
||||
@@ -230,8 +230,8 @@ pub fn invalidate_run_perms_cache() {
|
||||
}
|
||||
|
||||
/// Whether the caller may start `path`, as opposed to only reading it. Readers run unless every
|
||||
/// grant they read it through is view-only (`view_only` of the item or of its folder): run is the
|
||||
/// union of the grants, as read and write are. Call it on top of the read check the fetch of the
|
||||
/// grant they read it through is `"read"` (on the item or on its folder): run is the union of the
|
||||
/// grants, as read and write are. Call it on top of the read check the fetch of the
|
||||
/// runnable already does, and of the role's `run` capability, which stays the ceiling.
|
||||
pub async fn require_can_run(
|
||||
db: &DB,
|
||||
@@ -274,20 +274,20 @@ pub async fn require_can_run(
|
||||
"WITH item AS (
|
||||
-- The newest version only: a script reusing a retired path starts with no grants,
|
||||
-- and the retired versions' must not run it.
|
||||
(SELECT extra_perms, view_only FROM script
|
||||
(SELECT extra_perms FROM script
|
||||
WHERE $5 = 'script' AND workspace_id = $1 AND path = $2
|
||||
ORDER BY created_at DESC LIMIT 1)
|
||||
UNION ALL SELECT extra_perms, view_only FROM flow
|
||||
UNION ALL SELECT extra_perms FROM flow
|
||||
WHERE $5 = 'flow' AND workspace_id = $1 AND path = $2
|
||||
UNION ALL SELECT extra_perms, view_only FROM resource
|
||||
UNION ALL SELECT extra_perms FROM resource
|
||||
WHERE $5 = 'resource' AND workspace_id = $1 AND path = $2
|
||||
)
|
||||
SELECT EXISTS (
|
||||
SELECT 1 FROM item WHERE acl_grants_run(item.extra_perms, item.view_only, $4)
|
||||
SELECT 1 FROM item WHERE acl_grants_run(item.extra_perms, $4)
|
||||
) OR EXISTS (
|
||||
SELECT 1 FROM folder f
|
||||
WHERE f.workspace_id = $1 AND f.name = $3
|
||||
AND (f.owners::text[] && $4 OR acl_grants_run(f.extra_perms, f.view_only, $4))
|
||||
AND (f.owners::text[] && $4 OR acl_grants_run(f.extra_perms, $4))
|
||||
) AS \"can_run!\"",
|
||||
w_id,
|
||||
path,
|
||||
@@ -372,6 +372,11 @@ impl PermsCache {
|
||||
}
|
||||
}
|
||||
|
||||
/// Whether an `extra_perms` value grants write: `true` or `"write"`.
|
||||
pub fn acl_writes(v: &serde_json::Value) -> bool {
|
||||
v.as_bool().unwrap_or(false) || v.as_str() == Some("write")
|
||||
}
|
||||
|
||||
/// Check a user's access level against an `extra_perms` JSONB object.
|
||||
///
|
||||
/// Returns `None` if the user has no matching entry (no access).
|
||||
@@ -390,7 +395,7 @@ pub fn check_extra_perms(
|
||||
format!("{PERMISSIONED_AS_USER_PREFIX}{username}")
|
||||
};
|
||||
if let Some(v) = extra_perms.get(&user_key) {
|
||||
return Some(v.as_bool().unwrap_or(false));
|
||||
return Some(acl_writes(v));
|
||||
}
|
||||
|
||||
// Check group permissions — return highest access level found
|
||||
@@ -404,7 +409,7 @@ pub fn check_extra_perms(
|
||||
};
|
||||
if let Some(v) = extra_perms.get(&key) {
|
||||
found = true;
|
||||
if v.as_bool().unwrap_or(false) {
|
||||
if acl_writes(v) {
|
||||
write = true;
|
||||
break;
|
||||
}
|
||||
@@ -785,7 +790,7 @@ pub async fn get_folders_for_user<'e, E: sqlx::PgExecutor<'e>>(
|
||||
.collect::<Vec<_>>();
|
||||
perms.insert(0, format!("u/{}", username));
|
||||
let folders = sqlx::query!(
|
||||
"SELECT name, (EXISTS (SELECT 1 FROM (SELECT key, value FROM jsonb_each_text(extra_perms) WHERE key = ANY($1)) t WHERE value::boolean IS true)) as write, $1 && owners::text[] as owner FROM folder
|
||||
"SELECT name, (EXISTS (SELECT 1 FROM (SELECT key, value FROM jsonb_each_text(extra_perms) WHERE key = ANY($1)) t WHERE value IN ('true', 'write'))) as write, $1 && owners::text[] as owner FROM folder
|
||||
WHERE extra_perms ?| $1 AND workspace_id = $2",
|
||||
&perms[..],
|
||||
w_id,
|
||||
@@ -814,8 +819,8 @@ pub async fn get_view_only_folders_for_user<'e, E: sqlx::PgExecutor<'e>>(
|
||||
perms.push(format!("u/{}", username));
|
||||
let folders = sqlx::query_scalar!(
|
||||
"SELECT name FROM folder
|
||||
WHERE workspace_id = $2 AND extra_perms ?| $1 AND cardinality(view_only) > 0
|
||||
AND NOT owners::text[] && $1 AND NOT acl_grants_run(extra_perms, view_only, $1)",
|
||||
WHERE workspace_id = $2 AND extra_perms ?| $1
|
||||
AND NOT owners::text[] && $1 AND NOT acl_grants_run(extra_perms, $1)",
|
||||
&perms[..],
|
||||
w_id,
|
||||
)
|
||||
|
||||
@@ -139,7 +139,6 @@ async fn prefetch_cached_script_inner(
|
||||
deleted: script.deleted,
|
||||
is_template: script.is_template,
|
||||
extra_perms: script.extra_perms,
|
||||
view_only: script.view_only,
|
||||
lock: script.lock,
|
||||
lock_error_logs: script.lock_error_logs,
|
||||
language: script.language,
|
||||
@@ -460,7 +459,7 @@ pub async fn deploy_relocked_version(
|
||||
sqlx::query!("
|
||||
INSERT INTO script
|
||||
(workspace_id, hash, path, parent_hashes, summary, description, content, \
|
||||
created_by, schema, is_template, extra_perms, view_only, lock, language, kind, tag, \
|
||||
created_by, schema, is_template, extra_perms, lock, language, kind, tag, \
|
||||
envs, concurrent_limit, concurrency_time_window_s, cache_ttl, cache_ignore_s3_path, \
|
||||
dedicated_worker, ws_error_handler_muted, priority, restart_unless_cancelled, \
|
||||
delete_after_use, delete_after_secs, timeout, concurrency_key, visible_to_runner_only, auto_kind, \
|
||||
@@ -468,7 +467,7 @@ pub async fn deploy_relocked_version(
|
||||
job_token_scopes, lock_error_logs, created_at)
|
||||
|
||||
SELECT workspace_id, $1, path, array_prepend($2::bigint, COALESCE(parent_hashes, '{}'::bigint[])), summary, description, \
|
||||
content, created_by, schema, is_template, extra_perms, view_only, $4::text, language, kind, tag, \
|
||||
content, created_by, schema, is_template, extra_perms, $4::text, language, kind, tag, \
|
||||
envs, concurrent_limit, concurrency_time_window_s, cache_ttl, cache_ignore_s3_path, \
|
||||
dedicated_worker, ws_error_handler_muted, priority, restart_unless_cancelled, \
|
||||
delete_after_use, delete_after_secs, timeout, concurrency_key, visible_to_runner_only, auto_kind, \
|
||||
|
||||
@@ -169,10 +169,6 @@ pub struct Resource {
|
||||
pub description: Option<String>,
|
||||
pub resource_type: String,
|
||||
pub extra_perms: serde_json::Value,
|
||||
/// Principals of `extra_perms` that may view but not run it (AI agents).
|
||||
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||
#[sqlx(default)]
|
||||
pub view_only: Vec<String>,
|
||||
pub created_by: Option<String>,
|
||||
pub edited_at: Option<chrono::DateTime<chrono::Utc>>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
@@ -187,10 +183,6 @@ pub struct ListableResource {
|
||||
pub description: Option<String>,
|
||||
pub resource_type: String,
|
||||
pub extra_perms: serde_json::Value,
|
||||
/// Principals of `extra_perms` that may view but not run it (AI agents).
|
||||
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||
#[sqlx(default)]
|
||||
pub view_only: Vec<String>,
|
||||
pub created_by: Option<String>,
|
||||
pub edited_at: Option<chrono::DateTime<chrono::Utc>>,
|
||||
pub is_linked: Option<bool>,
|
||||
@@ -379,7 +371,6 @@ async fn list_resources(
|
||||
"resource.description",
|
||||
"resource_type",
|
||||
"resource.extra_perms",
|
||||
"resource.view_only",
|
||||
"(now() > account.expires_at) as is_expired",
|
||||
"variable.path IS NOT NULL as is_linked",
|
||||
"account.refresh_token != '' as is_refreshed",
|
||||
@@ -582,7 +573,6 @@ async fn list_resources(
|
||||
description,
|
||||
resource_type,
|
||||
extra_perms: serde_json::Value::Object(serde_json::Map::new()),
|
||||
view_only: vec![],
|
||||
created_by: None,
|
||||
edited_at: Some(row.created_at),
|
||||
is_linked: None,
|
||||
@@ -622,7 +612,7 @@ async fn get_resource(
|
||||
ListableResource,
|
||||
// `null::bool` columns align with the struct fields; deployed rows are never draft-only.
|
||||
"SELECT resource.workspace_id, resource.path, resource.value, resource.description,
|
||||
resource.resource_type, resource.extra_perms, resource.view_only, resource.created_by, resource.edited_at,
|
||||
resource.resource_type, resource.extra_perms, resource.created_by, resource.edited_at,
|
||||
resource.labels,
|
||||
folder_labels(resource.workspace_id, resource.path) as \"inherited_labels?\",
|
||||
(now() > account.expires_at) as is_expired, account.refresh_token != '' as is_refreshed,
|
||||
|
||||
@@ -29,10 +29,6 @@ pub struct Flow {
|
||||
pub archived: bool,
|
||||
pub schema: Option<Schema>,
|
||||
pub extra_perms: serde_json::Value,
|
||||
/// Principals of `extra_perms` that may view but not run it.
|
||||
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||
#[sqlx(default)]
|
||||
pub view_only: Vec<String>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub dedicated_worker: Option<bool>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
@@ -93,10 +89,6 @@ pub struct ListableFlow {
|
||||
pub edited_at: Option<chrono::DateTime<chrono::Utc>>,
|
||||
pub archived: bool,
|
||||
pub extra_perms: serde_json::Value,
|
||||
/// Principals of `extra_perms` that may view but not run it.
|
||||
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||
#[sqlx(default)]
|
||||
pub view_only: Vec<String>,
|
||||
pub starred: bool,
|
||||
/// `Some(true)` only on synthesised draft-only rows; `None` on deployed rows.
|
||||
/// See ListableScript in scripts.rs.
|
||||
|
||||
@@ -325,7 +325,7 @@ pub fn id_to_codebase_info(id: &str) -> CodebaseInfo {
|
||||
/// Shared across all query sites so a schema change only needs one edit.
|
||||
pub const SCRIPT_COLUMNS: &str = concat!(
|
||||
"workspace_id, hash, path, parent_hashes, summary, description, content, ",
|
||||
"created_by, created_at, archived, schema, deleted, is_template, extra_perms, view_only, ",
|
||||
"created_by, created_at, archived, schema, deleted, is_template, extra_perms, ",
|
||||
"lock, lock_error_logs, language, kind, tag, envs, ",
|
||||
"dedicated_worker, ws_error_handler_muted, priority, cache_ttl, cache_ignore_s3_path, ",
|
||||
"timeout, delete_after_use, delete_after_secs, restart_unless_cancelled, ",
|
||||
@@ -352,10 +352,6 @@ pub struct Script<SR> {
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub is_template: Option<bool>,
|
||||
pub extra_perms: serde_json::Value,
|
||||
/// Principals of `extra_perms` that may view but not run it.
|
||||
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||
#[sqlx(default)]
|
||||
pub view_only: Vec<String>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub lock: Option<String>,
|
||||
pub lock_error_logs: Option<String>,
|
||||
@@ -458,10 +454,6 @@ pub struct ListableScript {
|
||||
pub created_at: chrono::DateTime<chrono::Utc>,
|
||||
pub archived: bool,
|
||||
pub extra_perms: serde_json::Value,
|
||||
/// Principals of `extra_perms` that may view but not run it.
|
||||
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||
#[sqlx(default)]
|
||||
pub view_only: Vec<String>,
|
||||
pub language: ScriptLang,
|
||||
pub starred: bool,
|
||||
pub tag: Option<String>,
|
||||
|
||||
@@ -277,12 +277,10 @@ export async function pushFlow(
|
||||
// step both for the up-to-date short-circuit and after the deploy.
|
||||
const {
|
||||
extra_perms: localPerms,
|
||||
view_only: localViewOnly,
|
||||
job_token_scopes: localJobTokenScopes,
|
||||
...localFlowBody
|
||||
} = localFlow as FlowFile & {
|
||||
extra_perms?: Record<string, boolean>;
|
||||
view_only?: string[];
|
||||
};
|
||||
// Always sent, unlike the other settings: the server keeps a restriction the body omits,
|
||||
// so a flow.yaml without the key has to clear it explicitly.
|
||||
@@ -351,8 +349,6 @@ export async function pushFlow(
|
||||
remotePath.replaceAll(SEP, "/"),
|
||||
localPerms,
|
||||
(flow as any)?.extra_perms,
|
||||
localViewOnly,
|
||||
(flow as any)?.view_only,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,9 +18,7 @@ export interface FolderFile {
|
||||
summary: string | undefined;
|
||||
display_name: string | undefined;
|
||||
owners: Array<string> | undefined;
|
||||
extra_perms: { [record: string]: boolean } | undefined;
|
||||
/** Principals of `extra_perms` that may view what the folder holds but not run it. */
|
||||
view_only?: string[];
|
||||
extra_perms: { [record: string]: boolean | "read" | "run" | "write" } | undefined;
|
||||
default_permissioned_as?: Array<{ path_glob: string; permissioned_as: string }>;
|
||||
labels?: Array<string>;
|
||||
}
|
||||
|
||||
@@ -112,8 +112,6 @@ export interface ScriptFile {
|
||||
// (see applyExtraPermsDiff) — never through create_script — so a perm-only
|
||||
// change never bumps the script hash/version.
|
||||
extra_perms?: Record<string, boolean>;
|
||||
// Principals of `extra_perms` that may view the script but not run it.
|
||||
view_only?: string[];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -734,8 +732,6 @@ export async function handleFile(
|
||||
remotePath.replaceAll(SEP, "/"),
|
||||
(typed as any)?.extra_perms,
|
||||
(remote as any)?.extra_perms,
|
||||
(typed as any)?.view_only,
|
||||
(remote as any)?.view_only,
|
||||
);
|
||||
return true;
|
||||
}
|
||||
@@ -791,8 +787,6 @@ export async function handleFile(
|
||||
remotePath.replaceAll(SEP, "/"),
|
||||
(typed as any)?.extra_perms,
|
||||
(remote as any)?.extra_perms,
|
||||
(typed as any)?.view_only,
|
||||
(remote as any)?.view_only,
|
||||
);
|
||||
|
||||
return true;
|
||||
|
||||
@@ -270,7 +270,7 @@ export async function pushGroup(
|
||||
|
||||
// only consider extra_perms that concern actual members of the group
|
||||
const admins = Object.entries(remoteGroup.extra_perms ?? {})
|
||||
.filter(([k, v]) => v && remoteGroup.members?.includes(k.slice(2)))
|
||||
.filter(([k, v]) => (v === true || v === "write") && remoteGroup.members?.includes(k.slice(2)))
|
||||
.map(([k, _]) => k)
|
||||
.sort();
|
||||
group = {
|
||||
|
||||
+34
-32
@@ -5,7 +5,20 @@ import type { AddGranularAclsData } from "../../gen/types.gen.ts";
|
||||
|
||||
export type ExtraPermsKind = AddGranularAclsData["kind"];
|
||||
|
||||
type PermsMap = Record<string, boolean>;
|
||||
type Level = "read" | "run" | "write";
|
||||
type PermsMap = Record<string, Level>;
|
||||
|
||||
/** Kinds whose read grant does not include running: there `false` is "run" and `"read"` views
|
||||
* only. Elsewhere `false` and `"read"` are the same read grant. */
|
||||
const RUN_LEVEL_KINDS: string[] = ["script", "flow", "resource", "folder"];
|
||||
|
||||
/** A grant as the level it gives: `true` or `"write"`, `false` or `"run"`, or `"read"`. */
|
||||
function levelOf(value: unknown, runLevel: boolean): Level | undefined {
|
||||
if (value === true || value === "write") return "write";
|
||||
if (value === false || value === "run") return runLevel ? "run" : "read";
|
||||
if (value === "read") return "read";
|
||||
return undefined;
|
||||
}
|
||||
|
||||
type Normalized = {
|
||||
perms: PermsMap;
|
||||
@@ -17,7 +30,7 @@ type Normalized = {
|
||||
malformedTop: boolean;
|
||||
};
|
||||
|
||||
function normalize(value: unknown, source: string): Normalized {
|
||||
function normalize(value: unknown, source: string, runLevel: boolean): Normalized {
|
||||
const perms: PermsMap = {};
|
||||
const invalidOwners = new Set<string>();
|
||||
|
||||
@@ -30,7 +43,7 @@ function normalize(value: unknown, source: string): Normalized {
|
||||
if (value !== undefined && value !== null) {
|
||||
log.error(
|
||||
colors.red(
|
||||
`extra_perms: ${source} is not a {owner: boolean} map — skipping ACL sync to avoid clobbering remote ACLs`,
|
||||
`extra_perms: ${source} is not a {owner: grant} map — skipping ACL sync to avoid clobbering remote ACLs`,
|
||||
),
|
||||
);
|
||||
return { perms, invalidOwners, malformedTop: true };
|
||||
@@ -40,8 +53,9 @@ function normalize(value: unknown, source: string): Normalized {
|
||||
|
||||
const invalidList: string[] = [];
|
||||
for (const [k, v] of Object.entries(value as Record<string, unknown>)) {
|
||||
if (typeof v === "boolean") {
|
||||
perms[k] = v;
|
||||
const level = levelOf(v, runLevel);
|
||||
if (level !== undefined) {
|
||||
perms[k] = level;
|
||||
} else {
|
||||
invalidOwners.add(k);
|
||||
invalidList.push(k);
|
||||
@@ -50,7 +64,7 @@ function normalize(value: unknown, source: string): Normalized {
|
||||
if (invalidList.length > 0) {
|
||||
log.error(
|
||||
colors.red(
|
||||
`extra_perms: ${invalidList.length} invalid entry/entries in ${source} (non-boolean value, treating as "no opinion"): ${invalidList.join(", ")}`,
|
||||
`extra_perms: ${invalidList.length} invalid entry/entries in ${source} (not true, false, "read", "run" or "write", treating as "no opinion"): ${invalidList.join(", ")}`,
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -104,11 +118,6 @@ export async function applyExtraPermsDiff(
|
||||
path: string,
|
||||
local: unknown,
|
||||
remote: unknown,
|
||||
/** `view_only` of the yaml: the read grants that do not include running. Absent is "no
|
||||
* opinion" on that distinction, like an absent `extra_perms`, so a file written before it
|
||||
* existed neither promotes nor demotes anyone. */
|
||||
localViewOnly?: unknown,
|
||||
remoteViewOnly?: unknown,
|
||||
): Promise<number> {
|
||||
// Absent local field = "no opinion" — never call /acls/* in this case.
|
||||
// Crucially, this protects users who don't track ACLs in source from having
|
||||
@@ -117,33 +126,22 @@ export async function applyExtraPermsDiff(
|
||||
return 0;
|
||||
}
|
||||
|
||||
const localN = normalize(local, "local yaml");
|
||||
const runLevel = RUN_LEVEL_KINDS.includes(kind);
|
||||
const localN = normalize(local, "local yaml", runLevel);
|
||||
// Top-level malformed (array, primitive, etc.) → treat as "no opinion" so a
|
||||
// typo in yaml can never silently revoke every remote ACL.
|
||||
if (localN.malformedTop) {
|
||||
return 0;
|
||||
}
|
||||
const remoteN = normalize(remote, "remote response");
|
||||
const remoteN = normalize(remote, "remote response", runLevel);
|
||||
|
||||
const localPerms = localN.perms;
|
||||
const remotePerms = remoteN.perms;
|
||||
|
||||
const localVO = Array.isArray(localViewOnly)
|
||||
? new Set(localViewOnly.filter((x): x is string => typeof x === "string"))
|
||||
: undefined;
|
||||
const remoteVO = new Set(
|
||||
Array.isArray(remoteViewOnly)
|
||||
? remoteViewOnly.filter((x): x is string => typeof x === "string")
|
||||
: [],
|
||||
);
|
||||
|
||||
const toGrant: Array<[string, boolean, "read" | "run" | undefined]> = [];
|
||||
for (const [owner, write] of Object.entries(localPerms)) {
|
||||
const level = write || !localVO ? undefined : localVO.has(owner) ? "read" : "run";
|
||||
const levelDrift =
|
||||
level !== undefined && owner in remotePerms && (level === "read") !== remoteVO.has(owner);
|
||||
if (!(owner in remotePerms) || remotePerms[owner] !== write || levelDrift) {
|
||||
toGrant.push([owner, write, level]);
|
||||
const toGrant: Array<[string, Level]> = [];
|
||||
for (const [owner, level] of Object.entries(localPerms)) {
|
||||
if (remotePerms[owner] !== level) {
|
||||
toGrant.push([owner, level]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -160,14 +158,18 @@ export async function applyExtraPermsDiff(
|
||||
}
|
||||
|
||||
let calls = 0;
|
||||
for (const [owner, write, level] of toGrant) {
|
||||
const access = write ? "write" : level === "read" ? "view only" : "read";
|
||||
for (const [owner, level] of toGrant) {
|
||||
const access = level === "read" && runLevel ? "view only" : level;
|
||||
try {
|
||||
await wmill.addGranularAcls({
|
||||
workspace,
|
||||
kind,
|
||||
path,
|
||||
requestBody: level ? { owner, write, level } : { owner, write },
|
||||
// Run and write as the `write` flag every server reads; `level` only for view-only.
|
||||
requestBody:
|
||||
level === "read" && runLevel
|
||||
? { owner, write: false, level }
|
||||
: { owner, write: level === "write" },
|
||||
});
|
||||
log.info(
|
||||
colors.green(
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
import { expect, test, beforeEach } from "bun:test";
|
||||
import { mockServices } from "./mock_services.ts";
|
||||
|
||||
const added: unknown[] = [];
|
||||
const removed: unknown[] = [];
|
||||
mockServices({
|
||||
addGranularAcls: async (req: { requestBody: unknown }) => {
|
||||
added.push(req.requestBody);
|
||||
return "";
|
||||
},
|
||||
removeGranularAcls: async (req: { requestBody: unknown }) => {
|
||||
removed.push(req.requestBody);
|
||||
return "";
|
||||
},
|
||||
});
|
||||
|
||||
const { applyExtraPermsDiff } = await import("../src/core/extra_perms.ts");
|
||||
|
||||
beforeEach(() => {
|
||||
added.length = 0;
|
||||
removed.length = 0;
|
||||
});
|
||||
|
||||
// A grant is the level it gives, whichever of its spellings a file or the server uses.
|
||||
test("booleans and level names of the same grant are in sync", async () => {
|
||||
const calls = await applyExtraPermsDiff(
|
||||
"ws",
|
||||
"script",
|
||||
"f/a/s",
|
||||
{ "u/a": true, "u/b": "run", "u/c": "read" },
|
||||
{ "u/a": "write", "u/b": false, "u/c": "read" },
|
||||
);
|
||||
expect(calls).toBe(0);
|
||||
});
|
||||
|
||||
test("view-only is granted by level where it exists, as a read grant elsewhere", async () => {
|
||||
await applyExtraPermsDiff("ws", "flow", "f/a/f", { "u/a": "read" }, { "u/a": false });
|
||||
await applyExtraPermsDiff("ws", "variable", "f/a/v", { "u/b": "read" }, { "u/b": false });
|
||||
await applyExtraPermsDiff("ws", "variable", "f/a/v", { "u/c": "run" }, {});
|
||||
expect(added).toEqual([
|
||||
{ owner: "u/a", write: false, level: "read" },
|
||||
{ owner: "u/c", write: false },
|
||||
]);
|
||||
});
|
||||
@@ -1,48 +0,0 @@
|
||||
import { expect, test, beforeEach } from "bun:test";
|
||||
import { mockServices } from "./mock_services.ts";
|
||||
|
||||
const added: unknown[] = [];
|
||||
mockServices({
|
||||
addGranularAcls: async (req: { requestBody: unknown }) => {
|
||||
added.push(req.requestBody);
|
||||
return "";
|
||||
},
|
||||
removeGranularAcls: async () => "",
|
||||
});
|
||||
|
||||
const { applyExtraPermsDiff } = await import("../src/core/extra_perms.ts");
|
||||
|
||||
beforeEach(() => {
|
||||
added.length = 0;
|
||||
});
|
||||
|
||||
// A yaml written before view-only grants existed has no `view_only`: it must neither promote a
|
||||
// remote view-only grant to run nor demote a new grant below run.
|
||||
test("an absent view_only leaves levels alone", async () => {
|
||||
await applyExtraPermsDiff(
|
||||
"ws",
|
||||
"script",
|
||||
"f/a/s",
|
||||
{ "u/viewer": false, "u/new": false },
|
||||
{ "u/viewer": false },
|
||||
undefined,
|
||||
["u/viewer"],
|
||||
);
|
||||
expect(added).toEqual([{ owner: "u/new", write: false }]);
|
||||
});
|
||||
|
||||
test("view_only moves a read grant between view and run", async () => {
|
||||
await applyExtraPermsDiff(
|
||||
"ws",
|
||||
"flow",
|
||||
"f/a/f",
|
||||
{ "u/a": false, "u/b": false },
|
||||
{ "u/a": false, "u/b": false },
|
||||
["u/a"],
|
||||
["u/b"],
|
||||
);
|
||||
expect(added).toEqual([
|
||||
{ owner: "u/a", write: false, level: "read" },
|
||||
{ owner: "u/b", write: false, level: "run" },
|
||||
]);
|
||||
});
|
||||
+22
-11
@@ -56,12 +56,25 @@ start further runs through the API either.
|
||||
### View-only grants
|
||||
|
||||
The same split exists per folder and per script, flow or AI agent: a read grant can withhold
|
||||
running (Viewer, below Runner and Writer). `extra_perms` keeps its `{principal: write}` booleans,
|
||||
which every RLS policy and client reads, and the principals whose read grant does not run are
|
||||
listed in a `view_only` column of `folder`, `script`, `flow` and `resource`. A grant made without a
|
||||
level (`write: false`, every grant from before levels) runs, and RLS is unchanged, so a viewer sees
|
||||
the item and, through its folder, its runs. Run is the union of a caller's grants, as read and
|
||||
write are: an item-level view-only grant does not withhold what the folder lets them run.
|
||||
running (Viewer, below Runner and Writer). It is the value of the principal's `extra_perms` entry:
|
||||
|
||||
| Value | Script, flow, agent (`resource`), folder | Every other kind |
|
||||
|---|---|---|
|
||||
| `true` or `"write"` | write | write |
|
||||
| `false` or `"run"` | run | read |
|
||||
| `"read"` | view only | read |
|
||||
|
||||
Readers (RLS policies, the backend, the frontend, the CLI) accept all five. Writers store `true`
|
||||
and `false`, and `"read"` only for a view-only grant, so a client that predates levels keeps
|
||||
reading every other grant; one that cannot read `"read"` skips that grant rather than revoking
|
||||
or widening it. Storing the names for every grant is a later step: its migration maps `false` to
|
||||
`"run"` on the first column and to `"read"` on the second, and it waits until the CLI pinned in
|
||||
the git-sync hub scripts reads them. The write policies of `script`, `flow` and `resource` compare
|
||||
the value as text (`IN ('true', 'write')`); a `::boolean` cast there fails every writer of a row
|
||||
whose own grant is `"read"`. A grant made without a level (`write: false`, every grant from before
|
||||
levels) runs, and the read policies only test that the key exists, so a viewer sees the item and,
|
||||
through its folder, its runs. Run is the union of a caller's grants, as read and write are: an
|
||||
item-level view-only grant does not withhold what the folder lets them run.
|
||||
|
||||
`windmill_common::auth::require_can_run` enforces it, on top of the RLS read and of the role's
|
||||
`run`, at each place that starts a deployed runnable for a caller: the run routes, restart, cancel
|
||||
@@ -71,11 +84,9 @@ owner on every fire. A schedule's later runs are not re-checked, as they were ne
|
||||
for read either: demoting its owner does not stop it. Flow steps, subflows and agent tools are not
|
||||
checked, as only the top-level run needs it. Cancel and run-now take run on the job or on one
|
||||
of its `parent_job` ancestors, as cancelling a job stops its descendants; a restart takes run on
|
||||
the flow it restarts. Its positive answers are cached, so every write that can take
|
||||
run away calls `notify_run_perms_change`; the cache's 60s expiry bounds what that cannot see, such
|
||||
as an item deleted and recreated without the grant. Anything that copies one of those rows (a new script
|
||||
version, a rename, a fork, a workspace rename) must copy `view_only` too: a copy that drops it
|
||||
turns its viewers into runners.
|
||||
the nearest of them with a runnable of its own. Its positive answers are cached, so every write
|
||||
that can take run away calls `notify_run_perms_change`; the cache's 60s expiry bounds what that
|
||||
cannot see, such as an item deleted and recreated without the grant.
|
||||
|
||||
Unlike `fork`, withdrawing `run` makes a role restricted: it is an enforced gate on hot routes,
|
||||
and the fast path is what spares every unrestricted caller a role lookup on each run. It does not
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
import { onMount, tick, untrack } from 'svelte'
|
||||
import Select from './select/Select.svelte'
|
||||
import { safeSelectItems } from './select/utils.svelte'
|
||||
import { aclWrites } from '$lib/utils'
|
||||
import TextInput from './text_input/TextInput.svelte'
|
||||
import PermissionHistory from './PermissionHistory.svelte'
|
||||
import { Minimatch } from 'minimatch'
|
||||
@@ -345,15 +346,14 @@
|
||||
}
|
||||
|
||||
function getRole(x: string): Role {
|
||||
const viewer = x in (folder?.extra_perms ?? {})
|
||||
const writer = viewer && (folder?.extra_perms ?? {})[x]
|
||||
const grant = (folder?.extra_perms ?? {})[x]
|
||||
const owner = folder?.owners?.includes(x)
|
||||
|
||||
if (owner) {
|
||||
return 'admin'
|
||||
} else if (writer) {
|
||||
} else if (aclWrites(grant)) {
|
||||
return 'writer'
|
||||
} else if ((folder?.view_only ?? []).includes(x)) {
|
||||
} else if (grant === 'read') {
|
||||
return 'viewer'
|
||||
} else {
|
||||
return 'runner'
|
||||
@@ -515,9 +515,11 @@
|
||||
default_permissioned_as: next.defaultPermissionedAs,
|
||||
owners: next.perms.filter((p) => p.role === 'admin').map((p) => p.owner_name),
|
||||
extra_perms: Object.fromEntries(
|
||||
next.perms.map((p) => [p.owner_name, p.role === 'writer' || p.role === 'admin'])
|
||||
),
|
||||
view_only: next.perms.filter((p) => p.role === 'viewer').map((p) => p.owner_name)
|
||||
next.perms.map((p) => [
|
||||
p.owner_name,
|
||||
p.role === 'viewer' ? 'read' : p.role === 'writer' || p.role === 'admin'
|
||||
])
|
||||
)
|
||||
}
|
||||
})
|
||||
sendUserToast(`Folder ${name} created`)
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { aclWrites } from '$lib/utils'
|
||||
import type { ExtraPerms } from '$lib/gen'
|
||||
import {
|
||||
GranularAclService,
|
||||
GroupService,
|
||||
@@ -86,7 +88,7 @@
|
||||
isDemoWorkspaceRestricted($operatingWorkspace, actingUser?.is_admin, actingUser?.is_super_admin)
|
||||
)
|
||||
|
||||
let groupPerms = $state<Record<string, boolean> | undefined>(undefined)
|
||||
let groupPerms = $state<ExtraPerms | undefined>(undefined)
|
||||
// A verdict that does not come from a loaded group: a new one is writable, one that failed
|
||||
// to load is not.
|
||||
let writeVerdict = $state<boolean | undefined>(undefined)
|
||||
@@ -218,7 +220,7 @@
|
||||
members: Array.from(
|
||||
new Set(
|
||||
Object.entries(group?.extra_perms ?? {})
|
||||
.filter(([k, v]) => k.startsWith('u/') && v)
|
||||
.filter(([k, v]) => k.startsWith('u/') && aclWrites(v))
|
||||
.map(([k, _]) => k.split('/')[1])
|
||||
.concat(group?.members ?? [])
|
||||
)
|
||||
@@ -238,7 +240,7 @@
|
||||
}
|
||||
|
||||
function getRole(x: string): GroupRole {
|
||||
const manages = 'u/' + x in (group?.extra_perms ?? {}) && (group?.extra_perms ?? {})['u/' + x]
|
||||
const manages = aclWrites((group?.extra_perms ?? {})['u/' + x])
|
||||
const belongs = group?.members?.includes(x)
|
||||
|
||||
if (manages && belongs) {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import type { ExtraPerms } from '$lib/gen'
|
||||
import type { Schema } from '$lib/common'
|
||||
import {
|
||||
GitSyncService,
|
||||
@@ -268,7 +269,7 @@
|
||||
function canEditResourceIn(
|
||||
ws: string,
|
||||
path: string,
|
||||
extraPerms: Record<string, boolean> | undefined
|
||||
extraPerms: ExtraPerms | undefined
|
||||
): boolean {
|
||||
const user = acting.in(ws)
|
||||
const caps = capabilitiesIn(
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import type { ExtraPerms } from '$lib/gen'
|
||||
import {
|
||||
computeSharableHash as computeSharableHash,
|
||||
defaultIfEmptyString,
|
||||
@@ -140,7 +141,7 @@
|
||||
can_write?: boolean
|
||||
created_at?: string
|
||||
created_by?: string
|
||||
extra_perms?: Record<string, boolean>
|
||||
extra_perms?: ExtraPerms
|
||||
}
|
||||
| undefined
|
||||
/** Set to refuse every write this form can make, and to say so when a run is
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import type { ExtraPerms } from '$lib/gen'
|
||||
import { SCRIPT_VIEW_SHOW_SCHEDULE_RUN_LATER } from '$lib/consts'
|
||||
import Label from './Label.svelte'
|
||||
import Toggle from './Toggle.svelte'
|
||||
@@ -21,7 +22,7 @@
|
||||
can_write?: boolean
|
||||
created_at?: string
|
||||
created_by?: string
|
||||
extra_perms?: Record<string, boolean>
|
||||
extra_perms?: ExtraPerms
|
||||
}
|
||||
| undefined
|
||||
scheduledForStr: string | undefined
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
<script lang="ts">
|
||||
import { aclWrites } from '$lib/utils'
|
||||
import type { ExtraPerms } from '$lib/gen'
|
||||
import { userStore } from '$lib/stores'
|
||||
import { Users } from 'lucide-svelte'
|
||||
import Badge from './common/badge/Badge.svelte'
|
||||
import Popover from './Popover.svelte'
|
||||
|
||||
interface Props {
|
||||
extraPerms?: Record<string, boolean>
|
||||
extraPerms?: ExtraPerms
|
||||
canWrite: boolean
|
||||
}
|
||||
|
||||
@@ -26,14 +28,16 @@
|
||||
let extraPermsKeys = Object.keys(extraPerms ?? {})
|
||||
|
||||
if (pusername in extraPermsKeys) {
|
||||
if (extraPerms?.[pusername]) {
|
||||
if (aclWrites(extraPerms?.[pusername])) {
|
||||
kd = 'write'
|
||||
} else {
|
||||
kd = 'read'
|
||||
}
|
||||
rson = 'This item was shared to you personally'
|
||||
} else {
|
||||
let writeGroup = pgroups.find((x) => extraPermsKeys.includes(x) && extraPerms?.[x])
|
||||
let writeGroup = pgroups.find(
|
||||
(x) => extraPermsKeys.includes(x) && aclWrites(extraPerms?.[x])
|
||||
)
|
||||
if (writeGroup) {
|
||||
kd = 'write'
|
||||
rson = `This item was write shared to the group ${writeGroup} which you are a member of`
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import type { ExtraPerms } from '$lib/gen'
|
||||
import { VariableService, WorkspaceService, type ListableVariable } from '$lib/gen'
|
||||
import { createEventDispatcher, onDestroy, untrack } from 'svelte'
|
||||
import { Button } from './common'
|
||||
@@ -99,7 +100,7 @@
|
||||
// deliberately unsupported: too unlikely to be worth guarding every read.
|
||||
let initialStates: Record<string, VariableState> = $state({})
|
||||
let existedInitially: Record<string, boolean> = $state({})
|
||||
let extraPerms: Record<string, Record<string, boolean>> = $state({})
|
||||
let extraPerms: Record<string, ExtraPerms> = $state({})
|
||||
let oauthLinked: Record<string, boolean> = $state({})
|
||||
let selected: string | undefined = $state(undefined)
|
||||
let pathError = $state('')
|
||||
@@ -163,7 +164,7 @@
|
||||
if (!perms || !acting.resolved(selected)) return undefined
|
||||
return canEditVariableIn(selected, perms)
|
||||
})
|
||||
function canEditVariableIn(ws: string, perms: Record<string, boolean>): boolean {
|
||||
function canEditVariableIn(ws: string, perms: ExtraPerms): boolean {
|
||||
const user = acting.in(ws)
|
||||
const caps = capabilitiesIn(
|
||||
user,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import type { ExtraPerms } from '$lib/gen'
|
||||
/*
|
||||
* WIN-2006: shared in-workspace app viewer (low-code AND raw). Renders the app
|
||||
* through the same PublicAppFrame -> PublicApp machinery the public viewer uses,
|
||||
@@ -67,9 +68,7 @@
|
||||
/** The app's own permissions, kept apart from the verdict: `loadPerms` resolves before the
|
||||
* acting user's `whoami` does in a workspace that is not the navigation one, and a verdict
|
||||
* computed there would stick at "cannot write" with nothing to recompute it. */
|
||||
let appPerms = $state<{ path: string; extraPerms: Record<string, boolean> } | undefined>(
|
||||
undefined
|
||||
)
|
||||
let appPerms = $state<{ path: string; extraPerms: ExtraPerms } | undefined>(undefined)
|
||||
/** Raw vs low-code, read from the app itself rather than from the route:
|
||||
* both kinds render here and either route serves either kind (links to a raw
|
||||
* app point at /apps/get all over the app), so only the app can say which
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { aclWrites } from '$lib/utils'
|
||||
import type { AclValue, ExtraPerms } from '$lib/gen'
|
||||
import { Alert, Drawer, DrawerContent } from '../common'
|
||||
import { VolumeService } from '$lib/gen'
|
||||
import { enterpriseLicense, workspaceStore, userStore } from '$lib/stores'
|
||||
@@ -68,9 +70,9 @@
|
||||
if ($userStore?.is_admin) return true
|
||||
const username = $userStore?.username
|
||||
if (username === createdBy || `u/${username}` === createdBy) return true
|
||||
if (extraPerms?.[`u/${username}`] === true) return true
|
||||
if (aclWrites(extraPerms?.[`u/${username}`] as AclValue)) return true
|
||||
const pgroups = $userStore?.pgroups ?? []
|
||||
return pgroups.some((g) => extraPerms?.[g] === true)
|
||||
return pgroups.some((g) => aclWrites(extraPerms?.[g] as AclValue))
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -137,10 +139,7 @@
|
||||
<div class="flex flex-col flex-1 min-w-0">
|
||||
<div class="flex items-center gap-1.5">
|
||||
<span class="text-sm font-medium truncate">{vol.name}</span>
|
||||
<SharedBadge
|
||||
extraPerms={vol.extra_perms as Record<string, boolean>}
|
||||
canWrite={writable}
|
||||
/>
|
||||
<SharedBadge extraPerms={vol.extra_perms as ExtraPerms} canWrite={writable} />
|
||||
</div>
|
||||
<span class="text-2xs text-secondary">
|
||||
{vol.file_count}
|
||||
|
||||
@@ -3562,7 +3562,7 @@ export const globalTools: SessionTool<{}>[] = [
|
||||
def: createToolDef(
|
||||
readWorkspaceItemSchema,
|
||||
'read_workspace_item',
|
||||
'Read one workspace item or draft. Prefers your draft when one exists; pass version: "deployed" to read the deployed state instead. A deployed item carries extraPerms (a draft does not; pass version: "deployed" for it): who it is shared with beyond its owner, as u/<user> or g/<group> → true (write) or false (read-only). A folder returns its owners and extraPerms; a group returns its members and extraPerms (who may manage it). For a folder or group, path is its name. A g/<group> entry grants every member of that group (g/all is everyone), and workspace admins can read and write every folder and item whatever these lists say.'
|
||||
'Read one workspace item or draft. Prefers your draft when one exists; pass version: "deployed" to read the deployed state instead. A deployed item carries extraPerms (a draft does not; pass version: "deployed" for it): who it is shared with beyond its owner, as u/<user> or g/<group> → true (write), false (read; on a script, flow, agent or folder also run) or "read" (view only: sees it and its runs, cannot run it). A folder returns its owners and extraPerms; a group returns its members and extraPerms (who may manage it). For a folder or group, path is its name. A g/<group> entry grants every member of that group (g/all is everyone), and workspace admins can read and write every folder and item whatever these lists say.'
|
||||
),
|
||||
planModeSafe: true,
|
||||
fn: async ({ args, workspace, toolId, toolCallbacks }) => {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import type { ExtraPerms } from '$lib/gen'
|
||||
import type {
|
||||
AzureTriggerData,
|
||||
CreateResource,
|
||||
@@ -156,7 +157,7 @@ export type WorkspaceItem = {
|
||||
/** Who a deployed item is shared with beyond its path owner, as `u/<user>` /
|
||||
* `g/<group>` → true for write, false for read-only. A draft has no permissions of
|
||||
* its own, so a draft read leaves it unset rather than reporting the item unshared. */
|
||||
extraPerms?: Record<string, boolean>
|
||||
extraPerms?: ExtraPerms
|
||||
isDraft: boolean
|
||||
isLiveDraft?: boolean
|
||||
}
|
||||
|
||||
@@ -157,7 +157,7 @@
|
||||
)
|
||||
// Unknown until the acting user resolves: the form offers a run meanwhile.
|
||||
const viewOnly = $derived(
|
||||
!!flow && !!actingUser && !canRun(flow.path, flow.extra_perms, flow.view_only, actingUser)
|
||||
!!flow && !!actingUser && !canRun(flow.path, flow.extra_perms, actingUser)
|
||||
)
|
||||
const promptForAi = $derived((flow?.schema?.prompt_for_ai as string | undefined) ?? '')
|
||||
let shareModal: ShareModal | undefined = $state()
|
||||
|
||||
@@ -185,10 +185,7 @@
|
||||
// Unknown until the acting user resolves: the form offers a run meanwhile, as it would to
|
||||
// anyone the server then lets through.
|
||||
const viewOnly = $derived(
|
||||
!isHubScript &&
|
||||
!!script &&
|
||||
!!actingUser &&
|
||||
!canRun(script.path, script.extra_perms, script.view_only, actingUser)
|
||||
!isHubScript && !!script && !!actingUser && !canRun(script.path, script.extra_perms, actingUser)
|
||||
)
|
||||
const editRights = useEditRights()
|
||||
const caps = $derived(editRights.capabilities)
|
||||
|
||||
@@ -116,7 +116,7 @@
|
||||
let viewOnly = $derived(
|
||||
!!grants.current &&
|
||||
!!operatingUser.current &&
|
||||
!canRun(path, grants.current.extra_perms, grants.current.view_only, operatingUser.current)
|
||||
!canRun(path, grants.current.extra_perms, operatingUser.current)
|
||||
)
|
||||
|
||||
// Recorded once the agent is in: a path with nothing deployed never loads one. Not from a
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import type { ExtraPerms } from '$lib/gen'
|
||||
import ResourceDescriptionField from '$lib/components/ResourceDescriptionField.svelte'
|
||||
import { Button, Drawer, DrawerContent } from '$lib/components/common'
|
||||
import Alert from '$lib/components/common/alert/Alert.svelte'
|
||||
@@ -122,7 +123,7 @@
|
||||
providerPath?: string
|
||||
providerOk: boolean
|
||||
/** The agent's own sharing, to tell whether this user may edit it. */
|
||||
extraPerms?: Record<string, boolean>
|
||||
extraPerms?: ExtraPerms
|
||||
/** The link cannot be read. `missing` (404): nothing exists at the path, the agent having been
|
||||
* renamed or deleted. `forbidden` (401/403): it exists and this user is refused it, a folder
|
||||
* they cannot read included, which says nothing about whether a run of the flow can read it.
|
||||
@@ -205,7 +206,7 @@
|
||||
fromDraft: draft != undefined,
|
||||
providerPath,
|
||||
providerOk,
|
||||
extraPerms: (response.extra_perms ?? {}) as Record<string, boolean>
|
||||
extraPerms: (response.extra_perms ?? {}) as ExtraPerms
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import type { ExtraPerms } from '$lib/gen'
|
||||
import {
|
||||
ResourceService,
|
||||
type FlowModule,
|
||||
@@ -126,7 +127,7 @@ export interface LinkedAgentDraft {
|
||||
/** No deployed row at this path, so deploying has to create rather than update. */
|
||||
noDeployed: boolean
|
||||
/** Of the deployed resource, for `agentDraftCanWrite`. */
|
||||
extraPerms: Record<string, boolean>
|
||||
extraPerms: ExtraPerms
|
||||
}
|
||||
|
||||
/** Whether `user`, holding a role with `caps`, may write this agent's resource.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { FolderService, GranularAclService, GroupService, UserService } from '$lib/gen'
|
||||
import type { Folder } from '$lib/gen'
|
||||
import type { ExtraPerms, Folder } from '$lib/gen'
|
||||
import { Button } from '$lib/components/common'
|
||||
import DropdownV2 from '$lib/components/DropdownV2.svelte'
|
||||
import Select from '$lib/components/select/Select.svelte'
|
||||
@@ -13,7 +13,7 @@
|
||||
import AccessHelp from './AccessHelp.svelte'
|
||||
import { untrack } from 'svelte'
|
||||
import { sendUserToast } from '$lib/toast'
|
||||
import { isOwner } from '$lib/utils'
|
||||
import { aclWrites, isOwner } from '$lib/utils'
|
||||
import { DEMO_RESTRICTION_HINT, isDemoWorkspaceRestricted } from '$lib/cloud'
|
||||
import { useScheduleLock, useTriggerLock } from '$lib/operatorWriteRights'
|
||||
import {
|
||||
@@ -86,8 +86,7 @@
|
||||
let canEdit = $derived(own && !inUseMode && !restricted && !writeLock)
|
||||
|
||||
let folder: Folder | undefined = $state()
|
||||
let saved: Record<string, boolean> = $state({})
|
||||
let viewOnly: string[] = $state([])
|
||||
let saved: ExtraPerms = $state({})
|
||||
// Every user and group of the workspace, for the Add people picker: loaded on its first use,
|
||||
// since it grows with the workspace and most opens of this list add no one.
|
||||
let principals: string[] | undefined = $state()
|
||||
@@ -110,10 +109,10 @@
|
||||
}
|
||||
let ownRows: ListRow[] = $derived(
|
||||
Object.entries(members)
|
||||
.map(([name, write]) => ({
|
||||
.map(([name, grant]) => ({
|
||||
name,
|
||||
write,
|
||||
viewOnly: !write && viewOnly.includes(name),
|
||||
write: aclWrites(grant),
|
||||
viewOnly: grant === 'read',
|
||||
source: 'Extra permission',
|
||||
editable: true
|
||||
}))
|
||||
@@ -177,23 +176,11 @@
|
||||
|
||||
async function loadAcls() {
|
||||
if (pending !== undefined) return
|
||||
const [acls, vo] = await Promise.all([
|
||||
GranularAclService.getGranularAcls({
|
||||
workspace: $operatingWorkspace!,
|
||||
path,
|
||||
kind: kind as any
|
||||
}),
|
||||
// Not gated on `runLevel`, which for a resource is only known once it has loaded.
|
||||
kind === 'script' || kind === 'flow' || kind === 'resource'
|
||||
? GranularAclService.getGranularAclsViewOnly({
|
||||
workspace: $operatingWorkspace!,
|
||||
path,
|
||||
kind: kind as any
|
||||
})
|
||||
: Promise.resolve([])
|
||||
])
|
||||
saved = acls
|
||||
viewOnly = vo
|
||||
saved = await GranularAclService.getGranularAcls({
|
||||
workspace: $operatingWorkspace!,
|
||||
path,
|
||||
kind: kind as any
|
||||
})
|
||||
loadGroupSizes()
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import type { Folder } from '$lib/gen'
|
||||
import type { ExtraPerms, Folder } from '$lib/gen'
|
||||
import { aclWrites } from '$lib/utils'
|
||||
|
||||
export type AccessRow = {
|
||||
/** `u/name` or `g/name`. */
|
||||
@@ -52,12 +53,13 @@ export function ownerLabel(path: string): string {
|
||||
export function accessLostByMove(
|
||||
from: InheritedAccess | undefined,
|
||||
to: InheritedAccess | undefined,
|
||||
members: Record<string, boolean>,
|
||||
members: ExtraPerms,
|
||||
groupMembers: Record<string, string[]> = {}
|
||||
): { lost: string[]; demoted: string[] } | undefined {
|
||||
if (!from || !to || from.note !== undefined || to.note !== undefined) return undefined
|
||||
const after = new Map<string, boolean>(to.rows.map((r) => [r.name, r.write]))
|
||||
for (const [name, write] of Object.entries(members)) after.set(name, after.get(name) || write)
|
||||
for (const [name, grant] of Object.entries(members))
|
||||
after.set(name, after.get(name) || aclWrites(grant))
|
||||
for (const [name, write] of [...after]) {
|
||||
for (const username of groupMembers[name] ?? []) {
|
||||
after.set(`u/${username}`, after.get(`u/${username}`) || write)
|
||||
@@ -93,10 +95,10 @@ export function inheritedAccess(
|
||||
const owners = folder.owners.map((owner) => ({ name: owner, write: true })).sort(byName)
|
||||
const members = Object.entries(folder.extra_perms ?? {})
|
||||
.filter(([member]) => !folder.owners.includes(member))
|
||||
.map(([member, write]) => ({
|
||||
.map(([member, grant]) => ({
|
||||
name: member,
|
||||
write: !!write,
|
||||
viewOnly: !write && (folder.view_only ?? []).includes(member)
|
||||
write: aclWrites(grant),
|
||||
...(grant === 'read' ? { viewOnly: true } : {})
|
||||
}))
|
||||
.sort(byName)
|
||||
return { source, rows: [...owners, ...members] }
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import type { ExtraPerms } from '$lib/gen'
|
||||
import { untrack } from 'svelte'
|
||||
import {
|
||||
clearPageDrawerAnchor,
|
||||
@@ -107,7 +108,7 @@
|
||||
let mode = $state<TriggerMode>('enabled')
|
||||
let dirtyPath = $state(false)
|
||||
let permsPath = $state<string | undefined>(undefined)
|
||||
let permsForWrite = $state<Record<string, boolean> | undefined>(undefined)
|
||||
let permsForWrite = $state<ExtraPerms | undefined>(undefined)
|
||||
// The acting user in the operating workspace arrives asynchronously, and an unknown user
|
||||
// refuses — so the editor stays read-only until the lookup lands, which is the safe answer.
|
||||
const can_write = $derived(
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import type { ExtraPerms } from '$lib/gen'
|
||||
import { Alert, Button } from '$lib/components/common'
|
||||
import {
|
||||
clearPageDrawerAnchor,
|
||||
@@ -55,7 +56,7 @@
|
||||
let dirtyPath = $state(false)
|
||||
const operatingUser = useOperatingUser()
|
||||
let permsPath = $state<string | undefined>(undefined)
|
||||
let permsForWrite = $state<Record<string, boolean> | undefined>(undefined)
|
||||
let permsForWrite = $state<ExtraPerms | undefined>(undefined)
|
||||
// The acting user in the operating workspace arrives asynchronously, and an unknown user
|
||||
// refuses — so the editor stays read-only until the lookup lands, which is the safe answer.
|
||||
const can_write = $derived(
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import type { ExtraPerms } from '$lib/gen'
|
||||
import { Button } from '$lib/components/common'
|
||||
import {
|
||||
clearPageDrawerAnchor,
|
||||
@@ -87,7 +88,7 @@
|
||||
let drawerLoading = $state(true)
|
||||
let showLoader = $state(false)
|
||||
let permsPath = $state<string | undefined>(undefined)
|
||||
let permsForWrite = $state<Record<string, boolean> | undefined>(undefined)
|
||||
let permsForWrite = $state<ExtraPerms | undefined>(undefined)
|
||||
// The acting user in the operating workspace arrives asynchronously, and an unknown user
|
||||
// refuses — so the editor stays read-only until the lookup lands, which is the safe answer.
|
||||
const can_write = $derived(
|
||||
@@ -95,7 +96,7 @@
|
||||
? editRights.roleCanAuthor('trigger')
|
||||
: editRights.canEditItem('trigger', permsPath, permsForWrite)
|
||||
)
|
||||
let extraPerms = $state<Record<string, boolean> | undefined>(undefined)
|
||||
let extraPerms = $state<ExtraPerms | undefined>(undefined)
|
||||
let errorHandler = $state(handlerDraftFromStored('error', undefined))
|
||||
const storedErrorHandler = $derived(handlerDraftToStored(errorHandler))
|
||||
const error_handler_path = $derived(storedErrorHandler.path)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import type { ExtraPerms } from '$lib/gen'
|
||||
import { Alert, Button } from '$lib/components/common'
|
||||
import {
|
||||
clearPageDrawerAnchor,
|
||||
@@ -64,7 +65,7 @@
|
||||
let dirtyPath = $state(false)
|
||||
const operatingUser = useOperatingUser()
|
||||
let permsPath = $state<string | undefined>(undefined)
|
||||
let permsForWrite = $state<Record<string, boolean> | undefined>(undefined)
|
||||
let permsForWrite = $state<ExtraPerms | undefined>(undefined)
|
||||
// The acting user in the operating workspace arrives asynchronously, and an unknown user
|
||||
// refuses — so the editor stays read-only until the lookup lands, which is the safe answer.
|
||||
const can_write = $derived(
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import type { ExtraPerms } from '$lib/gen'
|
||||
import { Button } from '$lib/components/common'
|
||||
import {
|
||||
clearPageDrawerAnchor,
|
||||
@@ -153,7 +154,7 @@
|
||||
let variable_path = $state('')
|
||||
let signature_options_type = $state<'custom_script' | 'custom_signature'>('custom_signature')
|
||||
let permsPath = $state<string | undefined>(undefined)
|
||||
let permsForWrite = $state<Record<string, boolean> | undefined>(undefined)
|
||||
let permsForWrite = $state<ExtraPerms | undefined>(undefined)
|
||||
// The acting user in the operating workspace arrives asynchronously, and an unknown user
|
||||
// refuses — so the editor stays read-only until the lookup lands, which is the safe answer.
|
||||
const can_write = $derived(
|
||||
@@ -161,7 +162,7 @@
|
||||
? editRights.roleCanAuthor('trigger')
|
||||
: editRights.canEditItem('trigger', permsPath, permsForWrite)
|
||||
)
|
||||
let extraPerms = $state<Record<string, boolean> | undefined>(undefined)
|
||||
let extraPerms = $state<ExtraPerms | undefined>(undefined)
|
||||
let summary: string | undefined = $state()
|
||||
let routeDescription: string | undefined = $state()
|
||||
let errorHandler = $state(handlerDraftFromStored('error', undefined))
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import type { ExtraPerms } from '$lib/gen'
|
||||
import { Alert, Button } from '$lib/components/common'
|
||||
import {
|
||||
clearPageDrawerAnchor,
|
||||
@@ -104,7 +105,7 @@
|
||||
let mode = $state<TriggerMode>('enabled')
|
||||
let dirtyPath = $state(false)
|
||||
let permsPath = $state<string | undefined>(undefined)
|
||||
let permsForWrite = $state<Record<string, boolean> | undefined>(undefined)
|
||||
let permsForWrite = $state<ExtraPerms | undefined>(undefined)
|
||||
// The acting user in the operating workspace arrives asynchronously, and an unknown user
|
||||
// refuses — so the editor stays read-only until the lookup lands, which is the safe answer.
|
||||
const can_write = $derived(
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import type { ExtraPerms } from '$lib/gen'
|
||||
import { untrack } from 'svelte'
|
||||
import {
|
||||
clearPageDrawerAnchor,
|
||||
@@ -113,7 +114,7 @@
|
||||
let mode = $state<TriggerMode>('enabled')
|
||||
let dirtyPath = $state(false)
|
||||
let permsPath = $state<string | undefined>(undefined)
|
||||
let permsForWrite = $state<Record<string, boolean> | undefined>(undefined)
|
||||
let permsForWrite = $state<ExtraPerms | undefined>(undefined)
|
||||
// The acting user in the operating workspace arrives asynchronously, and an unknown user
|
||||
// refuses — so the editor stays read-only until the lookup lands, which is the safe answer.
|
||||
const can_write = $derived(
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import type { ExtraPerms } from '$lib/gen'
|
||||
import { Alert, Button } from '$lib/components/common'
|
||||
import {
|
||||
clearPageDrawerAnchor,
|
||||
@@ -99,7 +100,7 @@
|
||||
let pathError = $state('')
|
||||
let dirtyPath = $state(false)
|
||||
let permsPath = $state<string | undefined>(undefined)
|
||||
let permsForWrite = $state<Record<string, boolean> | undefined>(undefined)
|
||||
let permsForWrite = $state<ExtraPerms | undefined>(undefined)
|
||||
// The acting user in the operating workspace arrives asynchronously, and an unknown user
|
||||
// refuses — so the editor stays read-only until the lookup lands, which is the safe answer.
|
||||
const can_write = $derived(
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import type { ExtraPerms } from '$lib/gen'
|
||||
import { Alert, Button, TabContent } from '$lib/components/common'
|
||||
import {
|
||||
clearPageDrawerAnchor,
|
||||
@@ -118,7 +119,7 @@
|
||||
let pathError = $state('')
|
||||
let dirtyPath: boolean = $state(false)
|
||||
let permsPath = $state<string | undefined>(undefined)
|
||||
let permsForWrite = $state<Record<string, boolean> | undefined>(undefined)
|
||||
let permsForWrite = $state<ExtraPerms | undefined>(undefined)
|
||||
// The acting user in the operating workspace arrives asynchronously, and an unknown user
|
||||
// refuses — so the editor stays read-only until the lookup lands, which is the safe answer.
|
||||
const can_write = $derived(
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import type { ExtraPerms } from '$lib/gen'
|
||||
import { Alert, Badge, Button, ButtonType } from '$lib/components/common'
|
||||
import {
|
||||
clearPageDrawerAnchor,
|
||||
@@ -104,7 +105,7 @@
|
||||
let drawerLoading = $state(true)
|
||||
let showLoading = $state(false)
|
||||
let initialConfig = $state<Record<string, any> | undefined>(undefined)
|
||||
let extraPerms: Record<string, boolean> = $state({})
|
||||
let extraPerms: ExtraPerms = $state({})
|
||||
// Path the permissions above were loaded for — the verdict is about the schedule as
|
||||
// stored, not about a rename being typed into the form. `undefined` until a config has
|
||||
// been loaded, when there is no deployed schedule to deny access to.
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user