mirror of https://github.com/buster-so/buster.git
list logs fix move dataset security
This commit is contained in:
parent
0fe248af72
commit
df1eda84d3
|
@ -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 {
|
||||
|
|
|
@ -9,6 +9,7 @@ members = [
|
|||
"libs/sharing",
|
||||
"libs/sql_analyzer",
|
||||
"libs/search",
|
||||
"libs/dataset_security",
|
||||
]
|
||||
resolver = "2"
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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
|
|
@ -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)
|
||||
}
|
||||
}
|
|
@ -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" }
|
|
@ -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"))
|
||||
|
|
|
@ -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)]
|
||||
|
|
Loading…
Reference in New Issue