Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

fix(documents): ensure view access for job processing results (#7770)

Will Hutchinson9cb8edf38696
diff --git a/services/document_storage_service/src/api/documents.rs b/services/document_storage_service/src/api/documents.rs
index c8045bdf99..ab232fd6b7 100644
--- a/services/document_storage_service/src/api/documents.rs
+++ b/services/document_storage_service/src/api/documents.rs
@@ -133,7 +133,8 @@ pub fn router(state: ApiContext) -> Router<ApiContext> {
.with_state(state)
.route(
"/{document_id}/processing/{job_id}",
- get(job_processing_result::job_processing_result_handler),
+ get(job_processing_result::job_processing_result_handler)
+ .layer(ensure_document_exists_middleware),
)
.route(
"/preview",
diff --git a/services/document_storage_service/src/api/documents/job_processing_result.rs b/services/document_storage_service/src/api/documents/job_processing_result.rs
index aed4f735f8..51bef966bd 100644
--- a/services/document_storage_service/src/api/documents/job_processing_result.rs
+++ b/services/document_storage_service/src/api/documents/job_processing_result.rs
@@ -1,14 +1,16 @@
-use crate::api::context::AuthorizationService;
+use crate::api::context::{AuthorizationService, EntityAccessService};
use crate::model::response::documents::get::GetDocumentProcessingResultResponse;
use axum::{
extract::{Path, State},
http::StatusCode,
response::IntoResponse,
};
+use entity_access::inbound::axum_extractors::DocumentAccessExtractor;
use macro_authorization::{OptionalMacroAuthorizationExtractor, UserOrInternalService};
use macro_db_client::document::get_document_process_content_from_job_id;
use model::response::GenericErrorResponse;
use model::response::GenericResponse;
+use models_permissions::share_permission::access_level::ViewAccessLevel;
use sqlx::PgPool;
#[derive(serde::Deserialize)]
@@ -33,8 +35,9 @@ pub struct Params {
(status = 500, body=GenericErrorResponse),
)
)]
-#[tracing::instrument(skip(db, user), fields(actor = tracing::field::Empty))]
+#[tracing::instrument(skip(db, user, _access), fields(actor = tracing::field::Empty))]
pub async fn job_processing_result_handler(
+ _access: DocumentAccessExtractor<ViewAccessLevel, EntityAccessService, AuthorizationService>,
State(db): State<PgPool>,
user: OptionalMacroAuthorizationExtractor<AuthorizationService, UserOrInternalService>,
Path(Params {