Skip to content

Commit 4998b68

Browse files
authored
Add Trino authorization row filter functionality (#292)
* Add Trino authorization row filter functionality - Introduced a new configuration file for Trino authorization, allowing row-level security filters to be defined for various tables. - Implemented the loading of Trino authorization configurations from a YAML file. - Added a new API endpoint for handling row filter requests, enabling dynamic filtering based on user permissions. - Updated the application state to include Trino authorization configuration and integrated it into the existing request handling logic. - Enhanced test coverage for the new row filter functionality, ensuring proper handling of various user permissions and configurations. This commit significantly improves the PDP server's capability to enforce row-level security in Trino, enhancing data access control based on user roles and attributes. * Add column masking functionality for Trino authorization - Introduced a new configuration for column masking in Trino, allowing sensitive data to be masked based on user permissions. - Implemented a new API endpoint at `/trino/batch-column-masking` to handle column mask requests. - Enhanced the Trino authorization configuration to include column masks, with support for multiple columns and custom actions. - Updated the application state and routing to integrate the new column masking functionality. - Improved test coverage for column masking, ensuring proper handling of various user permissions and configurations. This commit significantly enhances the PDP server's ability to enforce data privacy by masking sensitive information based on user roles and attributes. * Update row filter expression formatting in Trino authorization - Modified the row filter expression construction to wrap each expression in parentheses for improved clarity and consistency. - This change enhances the readability of the generated query strings used in authorization checks. This commit refines the handling of row filter expressions, contributing to better structured queries in the PDP server's Trino integration. * Log warning when unauthenticated Trino routes are enabled
1 parent 38a3016 commit 4998b68

File tree

15 files changed

+2271
-2
lines changed

15 files changed

+2271
-2
lines changed

pdp-server/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ redis = { version = "0.29.2", features = ["tokio-comp", "connection-manager"] }
2020
reqwest = { version = "0.12.15", features = ["json"] }
2121
serde = { version = "1.0.219", features = ["derive"] }
2222
serde_json = "1.0.140"
23+
serde_yaml = "0.9"
2324
sha2 = "0.10.8"
2425
thiserror = "2.0.12"
2526
tokio = { version = "1.44.1", features = ["full"] }
@@ -33,6 +34,7 @@ openssl = { version = "0.10", features = ["vendored"] } # Required for docker b
3334
async-trait = "0.1.88"
3435
redis-test = "0.9.0"
3536
reqwest = { version = "0.12.15", features = ["json"] }
37+
tempfile = "3.10"
3638
tokio = { version = "1.44.1", features = ["test-util"] }
3739
tower = "0.5.2"
3840
wiremock = "0.6.3"

pdp-server/src/api/health/checkers.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ mod tests {
183183
horizon_client: Arc::new(Client::new()),
184184
cache: Arc::new(Cache::Null(NullCache::new())),
185185
watchdog: None,
186+
trino_authz_config: None,
186187
}
187188
}
188189

pdp-server/src/api/horizon_fallback.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,7 @@ mod tests {
527527
use_new_authorized_users: false,
528528
allow_unauthenticated_trino: false,
529529
healthcheck_timeout: 1.0,
530+
trino_authz_config_path: "/tmp/trino-authz.yaml".to_string(),
530531
// Point to a non-existent server with a reserved port
531532
horizon: crate::config::horizon::HorizonConfig {
532533
host: "127.0.0.1".to_string(),
@@ -594,6 +595,7 @@ mod tests {
594595
use_new_authorized_users: false,
595596
allow_unauthenticated_trino: false,
596597
healthcheck_timeout: 1.0,
598+
trino_authz_config_path: "/tmp/trino-authz.yaml".to_string(),
597599
horizon: crate::config::horizon::HorizonConfig {
598600
host: horizon_mock.address().ip().to_string(),
599601
port: horizon_mock.address().port(),

pdp-server/src/api/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ pub(super) fn router(state: &AppState) -> Router<AppState> {
1515
let mut root = Router::new().merge(health::router());
1616

1717
if state.config.allow_unauthenticated_trino {
18+
log::warn!("[NOTICE] Unauthenticated Trino routes are enabled");
1819
root = root.merge(trino::router());
1920
}
2021

0 commit comments

Comments
 (0)