diff --git a/api/src/endpoints/common_enum.rs b/api/src/endpoints/common_enum.rs index 8018908b..59cf5c71 100644 --- a/api/src/endpoints/common_enum.rs +++ b/api/src/endpoints/common_enum.rs @@ -14,7 +14,7 @@ pub async fn read( query: Option>>, State(state): State>, ) -> Result>, ApiError> { - let mut query = shape_mongo_filter(query, None, None, false); + let mut query = shape_mongo_filter(query, None, None); query.filter.remove(DELETED_STR); let store = &state.app_stores.common_enum; diff --git a/api/src/endpoints/common_model.rs b/api/src/endpoints/common_model.rs index ef719ddb..a1b3baab 100644 --- a/api/src/endpoints/common_model.rs +++ b/api/src/endpoints/common_model.rs @@ -81,10 +81,6 @@ impl CrudHook for CreateRequest { impl CrudRequest for CreateRequest { type Output = CommonModel; - fn filterable() -> bool { - false - } - fn output(&self) -> Option { let mut record = Self::Output { id: Id::now(IdPrefix::CommonModel), diff --git a/api/src/endpoints/connection_definition.rs b/api/src/endpoints/connection_definition.rs index 716bb86c..816bc177 100644 --- a/api/src/endpoints/connection_definition.rs +++ b/api/src/endpoints/connection_definition.rs @@ -259,10 +259,6 @@ pub async fn public_get_connection_details( impl CrudRequest for CreateRequest { type Output = ConnectionDefinition; - fn filterable() -> bool { - false - } - fn output(&self) -> Option { let auth_secrets: Vec = self .authentication diff --git a/api/src/endpoints/connection_model_definition.rs b/api/src/endpoints/connection_model_definition.rs index c07bae1c..bbf3cd1f 100644 --- a/api/src/endpoints/connection_model_definition.rs +++ b/api/src/endpoints/connection_model_definition.rs @@ -303,10 +303,6 @@ impl CrudHook for CreateRequest {} impl CrudRequest for CreateRequest { type Output = ConnectionModelDefinition; - fn filterable() -> bool { - false - } - fn output(&self) -> Option { let key = format!( "api::{}::{}::{}::{}::{}::{}", diff --git a/api/src/endpoints/connection_model_schema.rs b/api/src/endpoints/connection_model_schema.rs index df81e8c0..ee767878 100644 --- a/api/src/endpoints/connection_model_schema.rs +++ b/api/src/endpoints/connection_model_schema.rs @@ -88,10 +88,6 @@ impl CrudHook for CreateRequest {} impl CrudRequest for CreateRequest { type Output = ConnectionModelSchema; - fn filterable() -> bool { - false - } - fn output(&self) -> Option { let key = format!( "api::{}::{}::{}", diff --git a/api/src/endpoints/connection_oauth_definition.rs b/api/src/endpoints/connection_oauth_definition.rs index 936580a6..8a82edc9 100644 --- a/api/src/endpoints/connection_oauth_definition.rs +++ b/api/src/endpoints/connection_oauth_definition.rs @@ -67,10 +67,6 @@ fn default_separator() -> Option { impl CrudRequest for CreateRequest { type Output = ConnectionOAuthDefinition; - fn filterable() -> bool { - false - } - fn output(&self) -> Option { Some(Self::Output { id: Id::new(IdPrefix::ConnectionOAuthDefinition, Utc::now()), diff --git a/api/src/endpoints/mod.rs b/api/src/endpoints/mod.rs index 86e189c0..aba428b6 100644 --- a/api/src/endpoints/mod.rs +++ b/api/src/endpoints/mod.rs @@ -66,11 +66,6 @@ pub trait CrudRequest: Sized { /// Update the output of the request based on the input. fn update(&self, _: &mut Self::Output) -> Unit {} - /// Whether the Output can be filtered by the environment and ownership. - fn filterable() -> bool { - true - } - /// Get the store for the request. fn get_store(stores: AppStores) -> MongoStore; } @@ -180,7 +175,6 @@ where e }), Some(headers), - T::filterable(), ); let store = T::get_store(state.app_stores.clone()); @@ -222,7 +216,7 @@ where let res = cache .try_get_with(query.as_ref().map(|q| q.0.clone()), async { - let query = shape_mongo_filter(query, None, None, T::filterable()); + let query = shape_mongo_filter(query, None, None); println!("{:?}", query); let store = T::get_store(state.app_stores.clone()); @@ -282,7 +276,6 @@ where e }), None, - T::filterable(), ); query.filter.insert("_id", id.clone()); @@ -348,7 +341,6 @@ where e }), None, - T::filterable(), ); query.filter.insert("_id", id.clone()); diff --git a/api/src/routes/private.rs b/api/src/routes/private.rs index 918f5702..ff63ebe7 100644 --- a/api/src/routes/private.rs +++ b/api/src/routes/private.rs @@ -4,15 +4,11 @@ use crate::{ connection_model_definition::{self, test_connection_model_definition}, connection_model_schema, connection_oauth_definition, openapi, }, - middleware::{ - extractor::OwnershipId, - jwt_auth::{self, JwtState}, - }, + middleware::jwt_auth::{self, JwtState}, server::AppState, }; use axum::{middleware::from_fn_with_state, routing::post, Router}; use std::sync::Arc; -use tower_governor::{governor::GovernorConfigBuilder, GovernorLayer}; use tower_http::trace::TraceLayer; pub async fn get_router(state: &Arc) -> Router> { @@ -40,20 +36,7 @@ pub async fn get_router(state: &Arc) -> Router> { ) .nest("/common-models", common_model::get_router()); - let config = Box::new( - GovernorConfigBuilder::default() - .per_second(state.config.burst_rate_limit) - .burst_size(state.config.burst_size) - .key_extractor(OwnershipId) - .use_headers() - .finish() - .expect("Failed to build GovernorConfig"), - ); - routes - .layer(GovernorLayer { - config: Box::leak(config), - }) .layer(from_fn_with_state( Arc::new(JwtState::new(state)), jwt_auth::jwt_auth, diff --git a/api/src/util/shape_mongo_filter.rs b/api/src/util/shape_mongo_filter.rs index ae237608..09cb3b21 100644 --- a/api/src/util/shape_mongo_filter.rs +++ b/api/src/util/shape_mongo_filter.rs @@ -22,7 +22,6 @@ pub fn shape_mongo_filter( query: Option>>, event_access: Option>, headers: Option, - is_filterable: bool, ) -> MongoQuery { let mut filter = doc! {}; let mut skip = 0; @@ -46,7 +45,7 @@ pub fn shape_mongo_filter( filter.insert(DELETED_STR, false); - if is_filterable && event_access.is_some() { + if event_access.is_some() { filter.insert( OWNERSHIP_STR, event_access.as_ref().unwrap().ownership.id.to_string(), @@ -107,7 +106,7 @@ mod test { filter: mut doc, skip, limit, - } = shape_mongo_filter(Some(Query(params.clone())), None, None, false); + } = shape_mongo_filter(Some(Query(params.clone())), None, None); assert_eq!(doc.get_str(OWNERSHIP_STR).unwrap(), "foo"); assert_eq!(doc.get_str(ENVIRONMENT_STR).unwrap(), "bar"); assert!(!doc.get_bool(DELETED_STR).unwrap()); @@ -134,7 +133,7 @@ mod test { }); let MongoQuery { filter: doc, .. } = - shape_mongo_filter(Some(Query(params)), Some(event_access), None, true); + shape_mongo_filter(Some(Query(params)), Some(event_access), None); assert_eq!(doc.get_str(OWNERSHIP_STR).unwrap(), "baz"); assert_eq!(doc.get_str(ENVIRONMENT_STR).unwrap(), "test"); } @@ -170,7 +169,6 @@ mod test { Some(Query(params.clone())), Some(event_access), Some(headers), - true, ); assert!(!doc.contains_key(ENVIRONMENT_STR));