Compare commits

...
2 Commits
Author SHA1 Message Date
Victor Radael 526a3bddcd Merge pull request #158 from dadosfera/ft/rls-old-catalog
FEAT: Rls first change
2022-10-21 15:18:01 -03:00
Victor Radael 45108d3019 FEAT: Rls first change 2022-10-21 14:49:28 -03:00
3 changed files with 61 additions and 4 deletions
+58 -1
View File
@@ -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;
+2 -2
View File
@@ -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
View File
File diff suppressed because one or more lines are too long