Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
fix [properties-be] - allow view access for publicly shared entities (#446)
Daniel Kweon7e4e85258762
diff --git a/rust/cloud-storage/properties_service/src/api/mod.rs b/rust/cloud-storage/properties_service/src/api/mod.rsindex a3a88bfd01..17bfbae9c7 100644--- a/rust/cloud-storage/properties_service/src/api/mod.rs+++ b/rust/cloud-storage/properties_service/src/api/mod.rs@@ -43,10 +43,16 @@ fn api_router(app_state: ApiContext) -> Router {Router::new().nest("/properties",- properties::router().layer(axum::middleware::from_fn_with_state(- app_state.jwt_args.clone(),- macro_middleware::auth::decode_jwt::handler,- )),+ properties::router().layer(+ tower::ServiceBuilder::new()+ .layer(axum::middleware::from_fn(+ macro_middleware::auth::initialize_user_context::handler,+ ))+ .layer(axum::middleware::from_fn_with_state(+ app_state.jwt_args.clone(),+ macro_middleware::auth::attach_user::handler,+ )),+ ),).nest("/internal",diff --git a/rust/cloud-storage/properties_service/src/api/permissions.rs b/rust/cloud-storage/properties_service/src/api/permissions.rsindex 46bd0cc022..f5a973581d 100644--- a/rust/cloud-storage/properties_service/src/api/permissions.rs+++ b/rust/cloud-storage/properties_service/src/api/permissions.rs@@ -29,6 +29,7 @@ impl PermissionError {/// Checks if a user has view access to an entity (View, Comment, Edit, or Owner level)./// Supports: Document, Chat, Project, Thread, Channel, Macro.+/// For anonymous users (empty user_id), only allows access to publicly shared entities.#[tracing::instrument(skip(context), fields(user_id = %user_id, entity_id = %entity_ref.entity_id, entity_type = ?entity_ref.entity_type))]pub async fn check_entity_view_permission(context: &ApiContext,diff --git a/rust/cloud-storage/properties_service/src/api/properties/mod.rs b/rust/cloud-storage/properties_service/src/api/properties/mod.rsindex 27e185e524..edbea244b0 100644--- a/rust/cloud-storage/properties_service/src/api/properties/mod.rs+++ b/rust/cloud-storage/properties_service/src/api/properties/mod.rs@@ -10,37 +10,46 @@ pub mod metadata;pub mod options;pub fn router() -> Router<ApiContext> {+ let ensure_user_exists =+ axum::middleware::from_fn(macro_middleware::auth::ensure_user_exists::handler);+Router::new()- // Property Definition Management - Unified endpoint with query params+ // Property Definition Management - requires authentication.route("/definitions",get(definitions::list::list_properties)- .post(definitions::create::create_property_definition),+ .post(definitions::create::create_property_definition)+ .layer(ensure_user_exists.clone()),).route("/definitions/:definition_id",- delete(definitions::delete::delete_property_definition),+ delete(definitions::delete::delete_property_definition)+ .layer(ensure_user_exists.clone()),)- // Property Options Management+ // Property Options Management - requires authentication.route("/definitions/:definition_id/options",- get(options::get::get_property_options).post(options::create::add_property_option),+ get(options::get::get_property_options)+ .post(options::create::add_property_option)+ .layer(ensure_user_exists.clone()),).route("/definitions/:definition_id/options/:option_id",- delete(options::delete::delete_property_option),+ delete(options::delete::delete_property_option).layer(ensure_user_exists.clone()),)// Entity Property Operations+ // GET allows anonymous access for public entities.route("/entities/:entity_type/:entity_id",get(entities::get::get_entity_properties),)+ // PUT/DELETE require authentication.route("/entities/:entity_type/:entity_id/:property_id",- put(entities::set::set_entity_property),+ put(entities::set::set_entity_property).layer(ensure_user_exists.clone()),).route("/entity_properties/:entity_property_id",- delete(entities::delete_property::delete_entity_property),+ delete(entities::delete_property::delete_entity_property).layer(ensure_user_exists),)}