From c602f6b1979dde088033cf353e4d9481ebd8d1ba Mon Sep 17 00:00:00 2001 From: David Christensen Date: Thu, 24 Oct 2024 12:52:21 -0500 Subject: [PATCH] Make permission checking conditional for DestReceiver (#56) Perform access checking at the CopyHook or in the UDFs themselves explicitly, instead of habing a lower-level perform this check. This allows us to use the DestReceiver in other code while allowing our own permission/hook checking there. --- src/arrow_parquet/uri_utils.rs | 52 +++++++++------------------------- src/lib.rs | 3 ++ src/parquet_copy_hook/hook.rs | 11 ++++++- src/parquet_udfs/metadata.rs | 7 ++++- src/parquet_udfs/schema.rs | 5 +++- 5 files changed, 37 insertions(+), 41 deletions(-) diff --git a/src/arrow_parquet/uri_utils.rs b/src/arrow_parquet/uri_utils.rs index 745058f..e1dc475 100644 --- a/src/arrow_parquet/uri_utils.rs +++ b/src/arrow_parquet/uri_utils.rs @@ -58,8 +58,6 @@ fn parse_bucket_and_key(uri: &Url) -> (String, String) { fn object_store_with_location(uri: &Url, copy_from: bool) -> (Arc, Path) { if uri.scheme() == "s3" { - ensure_object_store_access_privilege(copy_from); - let (bucket_name, key) = parse_bucket_and_key(uri); let storage_container = PG_BACKEND_TOKIO_RUNTIME @@ -71,8 +69,6 @@ fn object_store_with_location(uri: &Url, copy_from: bool) -> (Arc { let uri = parse_uri(&uri); + ensure_access_privilege_to_uri(&uri, true); let parquet_metadata = parquet_metadata_from_uri(&uri); let mut rows = vec![]; @@ -137,6 +140,7 @@ mod parquet { > { let uri = parse_uri(&uri); + ensure_access_privilege_to_uri(&uri, true); let parquet_metadata = parquet_metadata_from_uri(&uri); let created_by = parquet_metadata @@ -174,6 +178,7 @@ mod parquet { > { let uri = parse_uri(&uri); + ensure_access_privilege_to_uri(&uri, true); let parquet_metadata = parquet_metadata_from_uri(&uri); let kv_metadata = parquet_metadata.file_metadata().key_value_metadata(); diff --git a/src/parquet_udfs/schema.rs b/src/parquet_udfs/schema.rs index 7e5c68f..c2fcf00 100644 --- a/src/parquet_udfs/schema.rs +++ b/src/parquet_udfs/schema.rs @@ -1,4 +1,6 @@ -use crate::arrow_parquet::uri_utils::{parquet_schema_from_uri, parse_uri, uri_as_string}; +use crate::arrow_parquet::uri_utils::{ + ensure_access_privilege_to_uri, parquet_schema_from_uri, parse_uri, uri_as_string, +}; use ::parquet::{ format::{ConvertedType, FieldRepetitionType, LogicalType, Type}, @@ -32,6 +34,7 @@ mod parquet { > { let uri = parse_uri(&uri); + ensure_access_privilege_to_uri(&uri, true); let parquet_schema = parquet_schema_from_uri(&uri); let root_type = parquet_schema.root_schema();