mirror of https://github.com/buster-so/buster.git
lock down datasets to orgs
This commit is contained in:
parent
ea5589b4d8
commit
687cf6d072
|
@ -290,10 +290,15 @@ pub async fn get_permissioned_datasets(
|
||||||
return Ok(Vec::new()); // No datasets accessible
|
return Ok(Vec::new()); // No datasets accessible
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get all organization IDs for the user
|
||||||
|
let org_ids: Vec<Uuid> = user_orgs.into_iter().map(|(org_id, _)| org_id).collect();
|
||||||
|
|
||||||
// Fetch the actual dataset info for the combined IDs with pagination
|
// Fetch the actual dataset info for the combined IDs with pagination
|
||||||
|
// IMPORTANT: Filter by organization to prevent cross-org data access
|
||||||
let mut conn = get_pg_pool().get().await.context("DB Error")?; // Get final connection
|
let mut conn = get_pg_pool().get().await.context("DB Error")?; // Get final connection
|
||||||
datasets::table
|
datasets::table
|
||||||
.filter(datasets::id.eq_any(all_accessible_ids))
|
.filter(datasets::id.eq_any(all_accessible_ids))
|
||||||
|
.filter(datasets::organization_id.eq_any(org_ids))
|
||||||
.filter(datasets::deleted_at.is_null())
|
.filter(datasets::deleted_at.is_null())
|
||||||
.select(PermissionedDataset::as_select())
|
.select(PermissionedDataset::as_select())
|
||||||
.order(datasets::name.asc())
|
.order(datasets::name.asc())
|
||||||
|
|
|
@ -300,7 +300,11 @@ export async function getPermissionedDatasets(
|
||||||
return []; // No datasets accessible
|
return []; // No datasets accessible
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get all organization IDs for the user
|
||||||
|
const organizationIds = userOrgs.map(org => org.organizationId);
|
||||||
|
|
||||||
// Fetch the actual dataset info for the combined IDs with pagination
|
// Fetch the actual dataset info for the combined IDs with pagination
|
||||||
|
// IMPORTANT: Filter by organization to prevent cross-org data access
|
||||||
const results = await db
|
const results = await db
|
||||||
.select({
|
.select({
|
||||||
id: datasets.id,
|
id: datasets.id,
|
||||||
|
@ -312,7 +316,13 @@ export async function getPermissionedDatasets(
|
||||||
dataSourceId: datasets.dataSourceId,
|
dataSourceId: datasets.dataSourceId,
|
||||||
})
|
})
|
||||||
.from(datasets)
|
.from(datasets)
|
||||||
.where(and(inArray(datasets.id, Array.from(allAccessibleIds)), isNull(datasets.deletedAt)))
|
.where(
|
||||||
|
and(
|
||||||
|
inArray(datasets.id, Array.from(allAccessibleIds)),
|
||||||
|
inArray(datasets.organizationId, organizationIds),
|
||||||
|
isNull(datasets.deletedAt)
|
||||||
|
)
|
||||||
|
)
|
||||||
.orderBy(datasets.name)
|
.orderBy(datasets.name)
|
||||||
.limit(input.pageSize)
|
.limit(input.pageSize)
|
||||||
.offset(input.page * input.pageSize);
|
.offset(input.page * input.pageSize);
|
||||||
|
|
Loading…
Reference in New Issue