Skip to content

Commit 5f51f60

Browse files
committed
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.
1 parent 5e663a1 commit 5f51f60

File tree

12 files changed

+956
-2
lines changed

12 files changed

+956
-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/trino/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
pub mod allowed;
22
mod checks;
3+
pub mod row_filter;
34
pub mod schemas;
45

56
use crate::state::AppState;
@@ -8,5 +9,7 @@ use axum::Router;
89

910
/// Combines all Trino-related routes into a single router
1011
pub(super) fn router() -> Router<AppState> {
11-
Router::new().route("/trino/allowed", post(allowed::allowed_handler))
12+
Router::new()
13+
.route("/trino/allowed", post(allowed::allowed_handler))
14+
.route("/trino/row-filter", post(row_filter::row_filter_handler))
1215
}

0 commit comments

Comments
 (0)