list logs fix move dataset security

This commit is contained in:
dal 2025-04-17 11:38:21 -06:00
parent 0fe248af72
commit df1eda84d3
No known key found for this signature in database
GPG Key ID: 16F4B0E1E9F61122
8 changed files with 46 additions and 11 deletions

View File

@ -72,7 +72,7 @@ Example `lib.rs`:
//! This library provides...
// Re-export common workspace types if needed
pub use common_types::{Result, Error};
pub use anyhow::{Result, Error};
pub mod models;
pub mod utils;
@ -91,7 +91,7 @@ pub use models::{ImportantType, AnotherType};
Example `errors.rs`:
```rust
use thiserror::Error;
use common_types::Error as WorkspaceError;
use anyhow::Error as WorkspaceError;
#[derive(Error, Debug)]
pub enum Error {

View File

@ -9,6 +9,7 @@ members = [
"libs/sharing",
"libs/sql_analyzer",
"libs/search",
"libs/dataset_security",
]
resolver = "2"

View File

@ -72,7 +72,7 @@ Example `lib.rs`:
//! This library provides...
// Re-export common workspace types if needed
pub use common_types::{Result, Error};
pub use anyhow::{Result, Error};
pub mod models;
pub mod utils;
@ -91,7 +91,7 @@ pub use models::{ImportantType, AnotherType};
Example `errors.rs`:
```rust
use thiserror::Error;
use common_types::Error as WorkspaceError;
use anyhow::Error as WorkspaceError;
#[derive(Error, Debug)]
pub enum Error {

View File

@ -0,0 +1,20 @@
[package]
name = "dataset_security"
version = "0.1.0"
edition = "2021"
[dependencies]
# Workspace dependencies
anyhow = { workspace = true }
diesel = { workspace = true }
diesel-async = { workspace = true }
uuid = { workspace = true }
tracing = { workspace = true }
# Internal workspace dependencies
database = { path = "../database" }
# Development dependencies
[dev-dependencies]
tokio = { workspace = true }
# Add other workspace dev dependencies as needed

View File

@ -1,3 +1,5 @@
//! Library for handling dataset security and permissions.
use anyhow::{anyhow, Result};
use diesel::{BoolExpressionMethods, ExpressionMethods, JoinOnDsl, QueryDsl};
use diesel_async::RunQueryDsl;
@ -7,8 +9,11 @@ use database::{
pool::{get_pg_pool, PgPool},
models::Dataset,
schema::{
datasets, datasets_to_permission_groups, permission_groups,
permission_groups_to_identities, teams_to_users,
datasets,
datasets_to_permission_groups,
permission_groups,
permission_groups_to_identities,
teams_to_users,
},
};
@ -23,6 +28,8 @@ pub async fn get_permissioned_datasets(
Err(e) => return Err(anyhow!("Unable to get connection from pool: {}", e)),
};
// TODO: Add logic to check if user is admin, if so, return all datasets
let datasets = match datasets::table
.select(datasets::all_columns)
.inner_join(
@ -106,4 +113,4 @@ pub async fn has_dataset_access(user_id: &Uuid, dataset_id: &Uuid) -> Result<boo
};
Ok(has_dataset_access)
}
}

View File

@ -50,7 +50,13 @@ middleware = { path = "../libs/middleware" }
sharing = { path = "../libs/sharing" }
search = { path = "../libs/search" }
# Workspace Libraries
dataset_security = { path = "../libs/dataset_security" }
[dev-dependencies]
mockito = { workspace = true }
tokio-test = { workspace = true }
async-trait = { workspace = true }
async-trait = { workspace = true }
# Add the new dependency
# dataset_security = { path = "../libs/dataset_security" }

View File

@ -36,7 +36,7 @@ pub async fn list_logs_route(
};
match list_logs_handler(request, organization_id).await {
Ok(response) => Ok(ApiResponse::JsonData(response)),
Ok(response) => Ok(ApiResponse::JsonData(response.items)),
Err(e) => {
tracing::error!("Error listing logs: {}", e);
Err((StatusCode::INTERNAL_SERVER_ERROR, "Failed to list logs"))

View File

@ -4,7 +4,6 @@ use diesel::{BoolExpressionMethods, ExpressionMethods, JoinOnDsl, QueryDsl};
use indexmap::IndexMap;
use query_engine::data_source_query_routes::query_engine::query_engine;
use query_engine::data_types::DataType;
use rayon::iter::ParallelIterator;
use reqwest::StatusCode;
use uuid::Uuid;
@ -18,9 +17,11 @@ use database::{
types::DataMetadata,
};
use crate::{routes::rest::ApiResponse, utils::dataset_security::has_dataset_access};
use dataset_security::has_dataset_access;
use middleware::AuthenticatedUser;
use crate::routes::rest::ApiResponse;
const MAX_UNIQUE_VALUES: usize = 100;
#[derive(Serialize, Deserialize, Debug, Clone)]