This commit is contained in:
Ruben Fiszel
2026-02-06 15:49:52 +00:00
parent e8806c2733
commit 20541bcb5d
4 changed files with 5 additions and 50 deletions

View File

@@ -1,22 +0,0 @@
/*
* Author: Windmill Labs, Inc
* Copyright: Windmill Labs, Inc 2024
* This file and its contents are licensed under the AGPLv3 License.
* Please see the included NOTICE for copyright information and
* LICENSE-AGPL for a copy of the license.
*/
use windmill_api_auth::ApiAuthed;
use windmill_common::{error::Result, DB};
pub async fn require_is_writer(authed: &ApiAuthed, path: &str, w_id: &str, db: DB) -> Result<()> {
windmill_api_auth::permissions::require_is_writer(
authed,
path,
w_id,
db,
"SELECT extra_perms FROM flow WHERE path = $1 AND workspace_id = $2",
"flow",
)
.await
}

View File

@@ -12,7 +12,5 @@ pub mod native_triggers;
pub mod args_ext;
pub mod capture_ext;
pub mod flow_ext;
pub mod jobs_ext;
pub mod resource_ext;
pub mod script_ext;

View File

@@ -28,11 +28,12 @@ async fn require_is_writer_on_runnable(
w_id: &str,
db: DB,
) -> Result<()> {
if is_flow {
crate::flow_ext::require_is_writer(authed, path, w_id, db).await
let (query, kind) = if is_flow {
("SELECT extra_perms FROM flow WHERE path = $1 AND workspace_id = $2", "flow")
} else {
crate::script_ext::require_is_writer(authed, path, w_id, db).await
}
("SELECT extra_perms FROM script WHERE path = $1 AND workspace_id = $2 ORDER BY created_at DESC LIMIT 1", "script")
};
windmill_api_auth::permissions::require_is_writer(authed, path, w_id, db, query, kind).await
}
#[derive(Debug, Deserialize)]

View File

@@ -1,22 +0,0 @@
/*
* Author: Windmill Labs, Inc
* Copyright: Windmill Labs, Inc 2024
* This file and its contents are licensed under the AGPLv3 License.
* Please see the included NOTICE for copyright information and
* LICENSE-AGPL for a copy of the license.
*/
use windmill_api_auth::ApiAuthed;
use windmill_common::{error::Result, DB};
pub async fn require_is_writer(authed: &ApiAuthed, path: &str, w_id: &str, db: DB) -> Result<()> {
windmill_api_auth::permissions::require_is_writer(
authed,
path,
w_id,
db,
"SELECT extra_perms FROM script WHERE path = $1 AND workspace_id = $2 ORDER BY created_at DESC LIMIT 1",
"script",
)
.await
}