mirror of
https://github.com/dadosfera/maestro.git
synced 2026-11-15 15:19:09 +00:00
Merge pull request #158 from dadosfera/ft/rls-old-catalog
FEAT: Rls first change
This commit is contained in:
@@ -193,12 +193,69 @@ export class CatalogController {
|
||||
|
||||
const user_roles = await this.catalogService.getUserRolesIds(user_id);
|
||||
|
||||
const res = await this.catalogService.getOneDashboardMetabase(
|
||||
const res = await this.catalogService.getOneDashboardMetabase({
|
||||
id,
|
||||
body,
|
||||
metadata,
|
||||
customer_id,
|
||||
user_id: undefined,
|
||||
});
|
||||
|
||||
const dashboard = res.dashboard;
|
||||
|
||||
if (dashboard.owner === username) has_permission = true;
|
||||
|
||||
for (const role of user_roles) {
|
||||
if (dashboard.p_roles.includes(role)) has_permission = true;
|
||||
}
|
||||
|
||||
if (dashboard.p_users.includes(user_id)) has_permission = true;
|
||||
|
||||
if (is_data_manager || has_permission) {
|
||||
delete dashboard.p_roles;
|
||||
delete dashboard.p_users;
|
||||
return res;
|
||||
}
|
||||
|
||||
throw new HttpException(
|
||||
'You do not have permission to access this data asset.',
|
||||
403,
|
||||
);
|
||||
}
|
||||
|
||||
@Get('dashboard-metabase/rls/:id')
|
||||
async getOneDashboardMetabaseRls(
|
||||
@Body() body,
|
||||
@Param() params,
|
||||
@User() user: RequestUser,
|
||||
) {
|
||||
const { username, user_id, customer_id, customer_name, permissions } = user;
|
||||
const { id } = params;
|
||||
this.logger.info(`/catalog - ON GET ONE DASHBOARD METABASE ROUTE`, {
|
||||
username,
|
||||
customer_name,
|
||||
});
|
||||
|
||||
const is_data_manager = permissions.includes(
|
||||
PERMISSIONS_GROUPS.CATALOG.permissions.DATA_MANAGER.seqid,
|
||||
);
|
||||
let has_permission = false;
|
||||
const metadata = PackTheMetadata({
|
||||
username,
|
||||
user_id,
|
||||
customer_id,
|
||||
customer_name,
|
||||
});
|
||||
|
||||
const user_roles = await this.catalogService.getUserRolesIds(user_id);
|
||||
|
||||
const res = await this.catalogService.getOneDashboardMetabase({
|
||||
id,
|
||||
body,
|
||||
metadata,
|
||||
customer_id,
|
||||
user_id,
|
||||
});
|
||||
|
||||
const dashboard = res.dashboard;
|
||||
|
||||
|
||||
@@ -233,10 +233,10 @@ class CatalogService implements OnModuleInit {
|
||||
return { data_assets };
|
||||
}
|
||||
|
||||
async getOneDashboardMetabase(id, body, metadata, customer_id) {
|
||||
async getOneDashboardMetabase({ id, body, metadata, customer_id, user_id }) {
|
||||
const nimbusUrl = this._getNimbusUrl(body);
|
||||
const { data } = await axios.get(
|
||||
`${nimbusUrl}/api/catalog/dashboard-metabase/${id}`,
|
||||
`${nimbusUrl}/api/catalog/dashboard-metabase/${id}?user_id=${user_id}`,
|
||||
);
|
||||
|
||||
const { data_asset } = await lastValueFrom(
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user