From 381df43be4aaa9a25ad100bb3685ebdce145ac76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Renault?= Date: Wed, 24 Aug 2022 16:28:33 +0200 Subject: [PATCH] Change the metrics route API access rights --- meilisearch-auth/src/action.rs | 24 +++++++++++++++++------- meilisearch-http/src/routes/mod.rs | 2 +- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/meilisearch-auth/src/action.rs b/meilisearch-auth/src/action.rs index 94a15eb9d..fa4b7dbb0 100644 --- a/meilisearch-auth/src/action.rs +++ b/meilisearch-auth/src/action.rs @@ -41,6 +41,10 @@ pub enum Action { StatsAll = actions::STATS_ALL, #[serde(rename = "stats.get")] StatsGet = actions::STATS_GET, + #[serde(rename = "metrics.*")] + MetricsAll = actions::METRICS_ALL, + #[serde(rename = "metrics.get")] + MetricsGet = actions::METRICS_GET, #[serde(rename = "dumps.*")] DumpsAll = actions::DUMPS_ALL, #[serde(rename = "dumps.create")] @@ -79,6 +83,8 @@ impl Action { SETTINGS_UPDATE => Some(Self::SettingsUpdate), STATS_ALL => Some(Self::StatsAll), STATS_GET => Some(Self::StatsGet), + METRICS_ALL => Some(Self::MetricsAll), + METRICS_GET => Some(Self::MetricsGet), DUMPS_ALL => Some(Self::DumpsAll), DUMPS_CREATE => Some(Self::DumpsCreate), VERSION => Some(Self::Version), @@ -111,6 +117,8 @@ impl Action { Self::SettingsUpdate => SETTINGS_UPDATE, Self::StatsAll => STATS_ALL, Self::StatsGet => STATS_GET, + Self::MetricsAll => METRICS_ALL, + Self::MetricsGet => METRICS_GET, Self::DumpsAll => DUMPS_ALL, Self::DumpsCreate => DUMPS_CREATE, Self::Version => VERSION, @@ -141,11 +149,13 @@ pub mod actions { pub const SETTINGS_UPDATE: u8 = 15; pub const STATS_ALL: u8 = 16; pub const STATS_GET: u8 = 17; - pub const DUMPS_ALL: u8 = 18; - pub const DUMPS_CREATE: u8 = 19; - pub const VERSION: u8 = 20; - pub const KEYS_CREATE: u8 = 21; - pub const KEYS_GET: u8 = 22; - pub const KEYS_UPDATE: u8 = 23; - pub const KEYS_DELETE: u8 = 24; + pub const METRICS_ALL: u8 = 18; + pub const METRICS_GET: u8 = 19; + pub const DUMPS_ALL: u8 = 20; + pub const DUMPS_CREATE: u8 = 21; + pub const VERSION: u8 = 22; + pub const KEYS_CREATE: u8 = 23; + pub const KEYS_GET: u8 = 24; + pub const KEYS_UPDATE: u8 = 25; + pub const KEYS_DELETE: u8 = 26; } diff --git a/meilisearch-http/src/routes/mod.rs b/meilisearch-http/src/routes/mod.rs index 95b04641a..ff4a2801d 100644 --- a/meilisearch-http/src/routes/mod.rs +++ b/meilisearch-http/src/routes/mod.rs @@ -282,7 +282,7 @@ pub async fn get_health() -> Result { } pub async fn get_metrics( - meilisearch: GuardedData, MeiliSearch>, + meilisearch: GuardedData, MeiliSearch>, ) -> Result { let search_rules = &meilisearch.filters().search_rules; let response = meilisearch.get_all_stats(search_rules).await?;