diff --git a/crates/meilisearch-auth/src/store.rs b/crates/meilisearch-auth/src/store.rs index eb2170f08..470379e06 100644 --- a/crates/meilisearch-auth/src/store.rs +++ b/crates/meilisearch-auth/src/store.rs @@ -137,6 +137,14 @@ impl HeedAuthStore { Action::ChatsSettingsAll => { actions.extend([Action::ChatsSettingsGet, Action::ChatsSettingsUpdate]); } + Action::WebhooksAll => { + actions.extend([ + Action::WebhooksGet, + Action::WebhooksUpdate, + Action::WebhooksDelete, + Action::WebhooksCreate, + ]); + } other => { actions.insert(*other); } diff --git a/crates/meilisearch-types/src/keys.rs b/crates/meilisearch-types/src/keys.rs index 2eddb9547..6763e2661 100644 --- a/crates/meilisearch-types/src/keys.rs +++ b/crates/meilisearch-types/src/keys.rs @@ -371,6 +371,15 @@ pub enum Action { #[serde(rename = "webhooks.update")] #[deserr(rename = "webhooks.update")] WebhooksUpdate, + #[serde(rename = "webhooks.delete")] + #[deserr(rename = "webhooks.delete")] + WebhooksDelete, + #[serde(rename = "webhooks.create")] + #[deserr(rename = "webhooks.create")] + WebhooksCreate, + #[serde(rename = "webhooks.*")] + #[deserr(rename = "webhooks.*")] + WebhooksAll, } impl Action { @@ -436,7 +445,9 @@ impl Action { match self { // Any action that expands to others must return false, as it wouldn't be able to expand recursively. All | AllGet | DocumentsAll | IndexesAll | ChatsAll | TasksAll | SettingsAll - | StatsAll | MetricsAll | DumpsAll | SnapshotsAll | ChatsSettingsAll => false, + | StatsAll | MetricsAll | DumpsAll | SnapshotsAll | ChatsSettingsAll | WebhooksAll => { + false + } Search => true, DocumentsAdd => false, @@ -473,6 +484,8 @@ impl Action { ChatsSettingsUpdate => false, WebhooksGet => true, WebhooksUpdate => false, + WebhooksDelete => false, + WebhooksCreate => false, } } @@ -535,6 +548,9 @@ pub mod actions { pub const WEBHOOKS_GET: u8 = WebhooksGet.repr(); pub const WEBHOOKS_UPDATE: u8 = WebhooksUpdate.repr(); + pub const WEBHOOKS_DELETE: u8 = WebhooksDelete.repr(); + pub const WEBHOOKS_CREATE: u8 = WebhooksCreate.repr(); + pub const WEBHOOKS_ALL: u8 = WebhooksAll.repr(); } #[cfg(test)] @@ -592,6 +608,9 @@ pub(crate) mod test { assert!(AllGet.repr() == 44 && ALL_GET == 44); assert!(WebhooksGet.repr() == 45 && WEBHOOKS_GET == 45); assert!(WebhooksUpdate.repr() == 46 && WEBHOOKS_UPDATE == 46); + assert!(WebhooksDelete.repr() == 47 && WEBHOOKS_DELETE == 47); + assert!(WebhooksCreate.repr() == 48 && WEBHOOKS_CREATE == 48); + assert!(WebhooksAll.repr() == 49 && WEBHOOKS_ALL == 49); } #[test] diff --git a/crates/meilisearch/src/routes/webhooks.rs b/crates/meilisearch/src/routes/webhooks.rs index a362b8bb1..67036e0b5 100644 --- a/crates/meilisearch/src/routes/webhooks.rs +++ b/crates/meilisearch/src/routes/webhooks.rs @@ -269,7 +269,7 @@ async fn get_webhook( let webhook = webhooks.webhooks.remove(&uuid).ok_or(WebhookNotFound(uuid))?; let webhook = WebhookWithMetadata::from(uuid, webhook); - + debug!(returns = ?webhook, "Get webhook"); Ok(HttpResponse::Ok().json(webhook)) } @@ -294,7 +294,7 @@ async fn get_webhook( ) )] async fn post_webhook( - index_scheduler: GuardedData, Data>, + index_scheduler: GuardedData, Data>, webhook_settings: AwebJson, req: HttpRequest, analytics: Data, @@ -400,7 +400,7 @@ async fn patch_webhook( ) )] async fn delete_webhook( - index_scheduler: GuardedData, Data>, + index_scheduler: GuardedData, Data>, uuid: Path, req: HttpRequest, analytics: Data,