mirror of
https://github.com/dadosfera/maestro.git
synced 2026-08-31 19:58:21 +00:00
FIX: Individual data assets permissions
This commit is contained in:
@@ -3,6 +3,7 @@ import {
|
||||
Controller,
|
||||
Delete,
|
||||
Get,
|
||||
HttpException,
|
||||
Inject,
|
||||
Param,
|
||||
Post,
|
||||
@@ -172,7 +173,11 @@ export class CatalogController {
|
||||
customer: body.info.customer,
|
||||
});
|
||||
|
||||
const { username, user_id, customer_id, customer_name } = user;
|
||||
const { username, user_id, customer_id, customer_name, permissions } = user;
|
||||
const is_data_manager = permissions.includes(
|
||||
PERMISSIONS_GROUPS.CATALOG.permissions.DATA_MANAGER.seqid,
|
||||
);
|
||||
let has_permission = false;
|
||||
const metadata = PackTheMetadata({
|
||||
username,
|
||||
user_id,
|
||||
@@ -180,6 +185,8 @@ export class CatalogController {
|
||||
customer_name,
|
||||
});
|
||||
|
||||
const user_roles = await this.catalogService.getUserRolesIds(user_id);
|
||||
|
||||
const res = await this.catalogService.getOneDashboardMetabase(
|
||||
id,
|
||||
body,
|
||||
@@ -187,7 +194,22 @@ export class CatalogController {
|
||||
customer_id,
|
||||
);
|
||||
|
||||
return res;
|
||||
const dashboard = res.dashboard;
|
||||
|
||||
for (const role of user_roles) {
|
||||
if (dashboard.roles.includes(role)) has_permission = true;
|
||||
}
|
||||
|
||||
if (dashboard.users.includes(user_id)) has_permission = true;
|
||||
|
||||
if (is_data_manager || has_permission) {
|
||||
return res;
|
||||
}
|
||||
|
||||
throw new HttpException(
|
||||
'You do not have permission to access this data asset.',
|
||||
403,
|
||||
);
|
||||
}
|
||||
|
||||
@Get('table-metadata')
|
||||
|
||||
@@ -248,14 +248,15 @@ class CatalogService implements OnModuleInit {
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
...data,
|
||||
Object.assign(data.dashboard, {
|
||||
tags: opensearchTable.tags,
|
||||
description: opensearchTable.description || null,
|
||||
roles,
|
||||
users,
|
||||
owner,
|
||||
};
|
||||
});
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
async getAllTableMetadata(body) {
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user