fix: git sync include changing permissions on folders

This commit is contained in:
Ruben Fiszel
2024-01-26 09:26:33 +01:00
parent 8da1d820a9
commit 2dd0411727
14 changed files with 102 additions and 4 deletions
@@ -48,6 +48,7 @@
"bash",
"postgresql",
"nativets",
"Nativets",
"bun",
"mysql",
"bigquery",
@@ -69,6 +69,7 @@
"bash",
"postgresql",
"nativets",
"Nativets",
"bun",
"mysql",
"bigquery",
@@ -28,6 +28,7 @@
"bash",
"postgresql",
"nativets",
"Nativets",
"bun",
"mysql",
"bigquery",
@@ -42,6 +42,7 @@
"bash",
"postgresql",
"nativets",
"Nativets",
"bun",
"mysql",
"bigquery",
@@ -62,6 +62,7 @@
"bash",
"postgresql",
"nativets",
"Nativets",
"bun",
"mysql",
"bigquery",
@@ -5,7 +5,7 @@
"columns": [
{
"ordinal": 0,
"name": "bool",
"name": "?column?",
"type_info": "Bool"
}
],
@@ -37,6 +37,7 @@
"bash",
"postgresql",
"nativets",
"Nativets",
"bun",
"mysql",
"bigquery",
@@ -0,0 +1,23 @@
{
"db_name": "PostgreSQL",
"query": "SELECT app.versions[array_upper(app.versions, 1)] FROM app WHERE path = $1 AND workspace_id = $2",
"describe": {
"columns": [
{
"ordinal": 0,
"name": "versions",
"type_info": "Int8"
}
],
"parameters": {
"Left": [
"Text",
"Text"
]
},
"nullable": [
null
]
},
"hash": "7bb9808f744590c0a962053e28564a37b980d3e9b1ceb23f69b9729b73e0bd33"
}
@@ -42,6 +42,7 @@
"bash",
"postgresql",
"nativets",
"Nativets",
"bun",
"mysql",
"bigquery",
@@ -42,6 +42,7 @@
"bash",
"postgresql",
"nativets",
"Nativets",
"bun",
"mysql",
"bigquery",
@@ -42,6 +42,7 @@
"bash",
"postgresql",
"nativets",
"Nativets",
"bun",
"mysql",
"bigquery",
+29
View File
@@ -32,6 +32,7 @@ use windmill_common::{
use serde::{Deserialize, Serialize};
use sqlx::{FromRow, Postgres, Transaction};
use windmill_git_sync::{handle_deployment_metadata, DeployedObject};
pub fn workspaced_service() -> Router {
Router::new()
@@ -150,8 +151,10 @@ lazy_static! {
async fn create_folder(
authed: ApiAuthed,
Tokened { token }: Tokened,
Extension(db): Extension<DB>,
Extension(user_db): Extension<UserDB>,
Extension(webhook): Extension<WebhookShared>,
Extension(rsmq): Extension<Option<rsmq_async::MultiplexedRsmq>>,
Extension(cache): Extension<Arc<AuthCache>>,
Path(w_id): Path<String>,
Json(ng): Json<NewFolder>,
@@ -203,6 +206,18 @@ async fn create_folder(
.execute(&mut *tx)
.await?;
handle_deployment_metadata(
&authed.email,
&authed.username,
&db,
&w_id,
DeployedObject::Folder { path: format!("f/{}/folder.meta.*", ng.name) },
Some(format!("Folder '{}' created", ng.name)),
rsmq,
true,
)
.await?;
audit_log(
&mut *tx,
&authed.username,
@@ -450,7 +465,9 @@ async fn get_folder_usage(
async fn delete_folder(
authed: ApiAuthed,
Extension(db): Extension<DB>,
Extension(user_db): Extension<UserDB>,
Extension(rsmq): Extension<Option<rsmq_async::MultiplexedRsmq>>,
Extension(webhook): Extension<WebhookShared>,
Path((w_id, name)): Path<(String, String)>,
) -> Result<String> {
@@ -477,6 +494,18 @@ async fn delete_folder(
.await?;
tx.commit().await?;
handle_deployment_metadata(
&authed.email,
&authed.username,
&db,
&w_id,
DeployedObject::Folder { path: format!("f/{}/folder.meta.*", name) },
Some(format!("Folder '{}' deleted", name)),
rsmq,
true,
)
.await?;
webhook.send_message(
w_id.clone(),
WebhookMessage::DeleteFolder { workspace: w_id, name: name.clone() },
+38 -1
View File
@@ -12,6 +12,7 @@ use axum::{
routing::{get, post},
Json, Router,
};
use windmill_git_sync::{handle_deployment_metadata, DeployedObject};
use crate::db::ApiAuthed;
@@ -39,6 +40,7 @@ async fn add_granular_acl(
authed: ApiAuthed,
Extension(db): Extension<DB>,
Extension(user_db): Extension<UserDB>,
Extension(rsmq): Extension<Option<rsmq_async::MultiplexedRsmq>>,
Path((w_id, path)): Path<(String, StripPath)>,
Json(GranularAcl { owner, write }): Json<GranularAcl>,
) -> Result<String> {
@@ -79,6 +81,23 @@ async fn add_granular_acl(
let _ = not_found_if_none(obj_o, &kind, &path)?;
tx.commit().await?;
match kind {
"folder" => {
handle_deployment_metadata(
&authed.email,
&authed.username,
&db,
&w_id,
DeployedObject::Folder { path: format!("f/{}/folder.meta.*", path) },
Some(format!("Folder '{}' changed permissions", path)),
rsmq,
true,
)
.await?
}
_ => (),
}
Ok("Successfully modified granular acl".to_string())
}
@@ -86,6 +105,7 @@ async fn remove_granular_acl(
authed: ApiAuthed,
Extension(db): Extension<DB>,
Extension(user_db): Extension<UserDB>,
Extension(rsmq): Extension<Option<rsmq_async::MultiplexedRsmq>>,
Path((w_id, path)): Path<(String, StripPath)>,
Json(GranularAcl { owner, write: _ }): Json<GranularAcl>,
) -> Result<String> {
@@ -124,13 +144,30 @@ async fn remove_granular_acl(
))
.bind(owner)
.bind(path)
.bind(w_id)
.bind(&w_id)
.fetch_optional(&mut *tx)
.await?;
let _ = not_found_if_none(obj_o, &kind, &path)?;
tx.commit().await?;
match kind {
"folder" => {
handle_deployment_metadata(
&authed.email,
&authed.username,
&db,
&w_id,
DeployedObject::Folder { path: format!("f/{}/folder.meta.*", path) },
Some(format!("Folder '{}' changed permissions", path)),
rsmq,
true,
)
.await?
}
_ => (),
}
Ok("Successfully removed granular acl".to_string())
}
+2 -2
View File
@@ -26,7 +26,7 @@ pub enum DeployedObject {
Script { hash: ScriptHash, path: String, parent_path: Option<String> },
Flow { path: String, parent_path: Option<String> },
App { path: String, version: i64, parent_path: Option<String> },
Folder { path: String, parent_path: Option<String> },
Folder { path: String },
}
impl DeployedObject {
@@ -44,7 +44,7 @@ impl DeployedObject {
DeployedObject::Script { parent_path, .. } => parent_path.to_owned(),
DeployedObject::Flow { parent_path, .. } => parent_path.to_owned(),
DeployedObject::App { parent_path, .. } => parent_path.to_owned(),
DeployedObject::Folder { parent_path, .. } => parent_path.to_owned(),
DeployedObject::Folder { .. } => None,
}
}
}