FEAT: create RLS on pi-factory

This commit is contained in:
Gabriel Rosa
2024-08-07 18:16:20 -03:00
parent b0f9f5c77e
commit 5da47e5438
5 changed files with 81 additions and 5 deletions
+49
View File
@@ -4513,6 +4513,55 @@
]
}
},
"/catalog/rls-rule": {
"post": {
"operationId": "CatalogController_addRlsRule",
"parameters": [
{
"name": "dadosfera-lang",
"in": "header",
"required": false,
"schema": {
"enum": [
"pt-br",
"en-us"
],
"type": "string"
}
}
],
"responses": {
"200": {
"description": "",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/GetDatasetCatalogTaskRes"
}
}
}
},
"201": {
"description": "",
"content": {
"application/json": {
"schema": {
"type": "object"
}
}
}
}
},
"tags": [
"Catalog"
],
"security": [
{
"access-token": []
}
]
}
},
"/terms-of-use/token": {
"get": {
"operationId": "TermsOfUseController_getToken",
+4 -4
View File
@@ -13,7 +13,7 @@
"@aws-sdk/client-secrets-manager": "^3.414.0",
"@dadosfera/dadosfera-logs": "^1.0.0-beta.4",
"@dadosfera/protospack": "2.5.3",
"@dadosfera/protospack-v2": "3.33.1-beta.2",
"@dadosfera/protospack-v2": "3.34.0-beta.2",
"@grpc/grpc-js": "^1.9.3",
"@grpc/proto-loader": "^0.7.9",
"@nestjs/cli": "^9.5.0",
@@ -1404,9 +1404,9 @@
}
},
"node_modules/@dadosfera/protospack-v2": {
"version": "3.33.1-beta.2",
"resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com/npm/dadosfera-npm/@dadosfera/protospack-v2/-/protospack-v2-3.33.1-beta.2.tgz",
"integrity": "sha512-iXvJWacU8HcueIArw7iI5TLeHb6/ZSEUcDwPUjhiSddTGnq3+kHTDkon8UEzgmhyEDmUp3BT4hHuufQmzE46sA==",
"version": "3.34.0-beta.2",
"resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com/npm/dadosfera-npm/@dadosfera/protospack-v2/-/protospack-v2-3.34.0-beta.2.tgz",
"integrity": "sha512-exnu5CyFZNO0ILNSlLCtUYJZ3qrr4XFBvP2BJ0fyiWd64WlpCPrEMEnJwdLVsbjm4wPeQsqLbXtGn+/Zn0tjEw==",
"dependencies": {
"@grpc/grpc-js": "^1.9.3",
"rxjs": "^7.5.5"
+1 -1
View File
@@ -30,7 +30,7 @@
"@aws-sdk/client-secrets-manager": "^3.414.0",
"@dadosfera/dadosfera-logs": "^1.0.0-beta.4",
"@dadosfera/protospack": "2.5.3",
"@dadosfera/protospack-v2": "3.33.1-beta.2",
"@dadosfera/protospack-v2": "3.34.0-beta.2",
"@grpc/grpc-js": "^1.9.3",
"@grpc/proto-loader": "^0.7.9",
"@nestjs/cli": "^9.5.0",
+16
View File
@@ -633,4 +633,20 @@ export class CatalogController {
return response;
}
@Post('rls-rule')
@ApiOkResponse({ type: GetDatasetCatalogTaskRes })
async addRlsRule(@User() user: RequestUser, @Body() body) {
const { customer_id, customer_name, user_id, username } = user;
const metadata = PackTheMetadata({
customer_id,
customer_name,
user_id,
username,
});
console.log(body);
const response = await this.catalogService.addRlsRule(body, metadata);
return response;
}
}
+11
View File
@@ -19,6 +19,7 @@ import { UsersService } from '../users/users.service';
import { RolesService } from '../roles/roles.service';
import { Metadata } from '@grpc/grpc-js';
import { IUpdateDataRequest, TriggerCatalogReq } from './dtos';
import { AddRlsUserToDashboardRequest } from '@dadosfera/protospack-v2/dist/lib/Catalog/interfaces/messages';
class CatalogService implements OnModuleInit {
catalogReadService: ReadService.CatalogReadServices;
@@ -345,6 +346,16 @@ class CatalogService implements OnModuleInit {
);
return res;
}
async addRlsRule(data: AddRlsUserToDashboardRequest, metadata: Metadata) {
const newData: AddRlsUserToDashboardRequest = {
...data,
rls_option: `rls_email`,
};
const res = await lastValueFrom(
this.catalogWriteService.AddRlsUserToDashboard(newData, metadata),
);
return res;
}
}
export { CatalogService };