diff --git a/meilisearch-auth/src/lib.rs b/meilisearch-auth/src/lib.rs index ec4c817c6..e18998db1 100644 --- a/meilisearch-auth/src/lib.rs +++ b/meilisearch-auth/src/lib.rs @@ -158,7 +158,7 @@ impl AuthController { pub struct AuthFilter { search_rules: Option, key_authorized_indexes: SearchRules, - pub allow_index_creation: bool, + allow_index_creation: bool, } impl Default for AuthFilter { @@ -172,6 +172,11 @@ impl Default for AuthFilter { } impl AuthFilter { + #[inline] + pub fn allow_index_creation(&self) -> bool { + self.allow_index_creation + } + pub fn with_allowed_indexes(allowed_indexes: HashSet) -> Self { Self { search_rules: None, diff --git a/meilisearch/src/routes/indexes/documents.rs b/meilisearch/src/routes/indexes/documents.rs index 0c649ea5d..635469c4e 100644 --- a/meilisearch/src/routes/indexes/documents.rs +++ b/meilisearch/src/routes/indexes/documents.rs @@ -192,7 +192,7 @@ pub async fn replace_documents( analytics.add_documents(¶ms, index_scheduler.index(&index_uid).is_err(), &req); - let allow_index_creation = index_scheduler.filters().allow_index_creation; + let allow_index_creation = index_scheduler.filters().allow_index_creation(); let task = document_addition( extract_mime_type(&req)?, index_scheduler, @@ -223,7 +223,7 @@ pub async fn update_documents( analytics.update_documents(¶ms, index_scheduler.index(&index_uid).is_err(), &req); - let allow_index_creation = index_scheduler.filters().allow_index_creation; + let allow_index_creation = index_scheduler.filters().allow_index_creation(); let task = document_addition( extract_mime_type(&req)?, index_scheduler, diff --git a/meilisearch/src/routes/indexes/settings.rs b/meilisearch/src/routes/indexes/settings.rs index d10aec1a2..b1feb4e38 100644 --- a/meilisearch/src/routes/indexes/settings.rs +++ b/meilisearch/src/routes/indexes/settings.rs @@ -45,7 +45,7 @@ macro_rules! make_setting_route { let new_settings = Settings { $attr: Setting::Reset.into(), ..Default::default() }; - let allow_index_creation = index_scheduler.filters().allow_index_creation; + let allow_index_creation = index_scheduler.filters().allow_index_creation(); let task = KindWithContent::SettingsUpdate { index_uid: index_uid.to_string(), @@ -86,7 +86,7 @@ macro_rules! make_setting_route { ..Default::default() }; - let allow_index_creation = index_scheduler.filters().allow_index_creation; + let allow_index_creation = index_scheduler.filters().allow_index_creation(); let task = KindWithContent::SettingsUpdate { index_uid: index_uid.to_string(), @@ -560,7 +560,7 @@ pub async fn update_all( Some(&req), ); - let allow_index_creation = index_scheduler.filters().allow_index_creation; + let allow_index_creation = index_scheduler.filters().allow_index_creation(); let index_uid = IndexUid::try_from(index_uid.into_inner())?.into_inner(); let task = KindWithContent::SettingsUpdate { index_uid, @@ -596,7 +596,7 @@ pub async fn delete_all( let new_settings = Settings::cleared().into_unchecked(); - let allow_index_creation = index_scheduler.filters().allow_index_creation; + let allow_index_creation = index_scheduler.filters().allow_index_creation(); let index_uid = IndexUid::try_from(index_uid.into_inner())?.into_inner(); let task = KindWithContent::SettingsUpdate { index_uid,