mirror of
https://github.com/dadosfera/maestro.git
synced 2026-11-12 15:39:09 +00:00
Compare commits
49
Commits
+151
@@ -542,6 +542,123 @@
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"/auth/users/block": {
|
||||||
|
"post": {
|
||||||
|
"operationId": "AuthController_blockUsers",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "dadosfera-lang",
|
||||||
|
"in": "header",
|
||||||
|
"required": false,
|
||||||
|
"schema": {
|
||||||
|
"enum": [
|
||||||
|
"pt-br",
|
||||||
|
"en-us"
|
||||||
|
],
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "",
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"type": "object"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"tags": [
|
||||||
|
"Auth"
|
||||||
|
],
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"access-token": []
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/auth/users/unblock": {
|
||||||
|
"post": {
|
||||||
|
"operationId": "AuthController_unblockUsers",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "dadosfera-lang",
|
||||||
|
"in": "header",
|
||||||
|
"required": false,
|
||||||
|
"schema": {
|
||||||
|
"enum": [
|
||||||
|
"pt-br",
|
||||||
|
"en-us"
|
||||||
|
],
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "",
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"type": "object"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"tags": [
|
||||||
|
"Auth"
|
||||||
|
],
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"access-token": []
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/auth/users/reset": {
|
||||||
|
"post": {
|
||||||
|
"operationId": "AuthController_resetUsers",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "dadosfera-lang",
|
||||||
|
"in": "header",
|
||||||
|
"required": false,
|
||||||
|
"schema": {
|
||||||
|
"enum": [
|
||||||
|
"pt-br",
|
||||||
|
"en-us"
|
||||||
|
],
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "",
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"type": "object"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"tags": [
|
||||||
|
"Auth"
|
||||||
|
],
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"access-token": []
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
"/connections": {
|
"/connections": {
|
||||||
"post": {
|
"post": {
|
||||||
"operationId": "ConnectionController_createConnection",
|
"operationId": "ConnectionController_createConnection",
|
||||||
@@ -5466,6 +5583,28 @@
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"/customers/logs-dashboard": {
|
||||||
|
"get": {
|
||||||
|
"operationId": "CustomersController_getCustomerMixPanelLogsDashboard",
|
||||||
|
"parameters": [],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": ""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"tags": [
|
||||||
|
"Customers"
|
||||||
|
],
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"access-token": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"access-token": []
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
"/open-data/sharing-ocean-data": {
|
"/open-data/sharing-ocean-data": {
|
||||||
"post": {
|
"post": {
|
||||||
"operationId": "OpenDataController_createUser",
|
"operationId": "OpenDataController_createUser",
|
||||||
@@ -5489,6 +5628,14 @@
|
|||||||
"schema": {
|
"schema": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "origin",
|
||||||
|
"required": true,
|
||||||
|
"in": "header",
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"responses": {
|
"responses": {
|
||||||
@@ -5643,6 +5790,9 @@
|
|||||||
"name": {
|
"name": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
"displayName": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"tier": {
|
"tier": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
@@ -5663,6 +5813,7 @@
|
|||||||
"modules",
|
"modules",
|
||||||
"id",
|
"id",
|
||||||
"name",
|
"name",
|
||||||
|
"displayName",
|
||||||
"tier",
|
"tier",
|
||||||
"scheduleLimit",
|
"scheduleLimit",
|
||||||
"links",
|
"links",
|
||||||
|
|||||||
+2
-2
@@ -15,8 +15,8 @@ charts:
|
|||||||
- name: maestro.tr_factory_url
|
- name: maestro.tr_factory_url
|
||||||
value: in-factory.dadosfera.ai
|
value: in-factory.dadosfera.ai
|
||||||
- name: maestro.open_customer_id
|
- name: maestro.open_customer_id
|
||||||
value: f239718a-a271-4ef9-ae7e-02a2f0f3aa6e
|
value: b3e3dfe5-b992-4586-a73c-c0b0c00f615d
|
||||||
- name: maestro.open_group_id
|
- name: maestro.open_group_id
|
||||||
value: 401573bb-334f-44b2-b30e-88d4cea31ae9
|
value: c0afdcce-c5be-40d0-9d1d-2d271121f14a
|
||||||
- name: replicaCount
|
- name: replicaCount
|
||||||
value: 2
|
value: 2
|
||||||
|
|||||||
+3
-3
@@ -9,11 +9,11 @@ charts:
|
|||||||
- name: hostname
|
- name: hostname
|
||||||
value: maestro.stg.dadosfera.ai
|
value: maestro.stg.dadosfera.ai
|
||||||
- name: maestro.pi_factory_url
|
- name: maestro.pi_factory_url
|
||||||
value: pi-factory.dadosfera.ai
|
value: pi-factory.stg.dadosfera.ai
|
||||||
- name: maestro.in_factory_url
|
- name: maestro.in_factory_url
|
||||||
value: in-factory.dadosfera.ai
|
value: in-factory.stg.dadosfera.ai
|
||||||
- name: maestro.tr_factory_url
|
- name: maestro.tr_factory_url
|
||||||
value: in-factory.dadosfera.ai
|
value: in-factory.stg.dadosfera.ai
|
||||||
- name: maestro.open_customer_id
|
- name: maestro.open_customer_id
|
||||||
value: b3e3dfe5-b992-4586-a73c-c0b0c00f615d
|
value: b3e3dfe5-b992-4586-a73c-c0b0c00f615d
|
||||||
- name: maestro.open_group_id
|
- name: maestro.open_group_id
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
apiVersion: networking.k8s.io/v1
|
||||||
|
kind: Ingress
|
||||||
|
metadata:
|
||||||
|
annotations:
|
||||||
|
nginx.ingress.kubernetes.io/whitelist-source-range: "69.49.241.121/32" # hostgator ip
|
||||||
|
nginx.ingress.kubernetes.io/proxy-body-size: "0"
|
||||||
|
nginx.ingress.kubernetes.io/server-snippet: |
|
||||||
|
underscores_in_headers on;
|
||||||
|
ignore_invalid_headers on;
|
||||||
|
|
||||||
|
generation: 1
|
||||||
|
labels:
|
||||||
|
app: maestro
|
||||||
|
name: open-data
|
||||||
|
namespace: applications
|
||||||
|
spec:
|
||||||
|
ingressClassName: nginx
|
||||||
|
rules:
|
||||||
|
- host: {{ .Values.hostname }}
|
||||||
|
http:
|
||||||
|
paths:
|
||||||
|
- backend:
|
||||||
|
service:
|
||||||
|
name: maestro
|
||||||
|
port:
|
||||||
|
number: {{ .Values.ingress.port }}
|
||||||
|
path: /open-data/sharing-ocean-data
|
||||||
|
pathType: Prefix
|
||||||
Generated
+1557
-494
File diff suppressed because it is too large
Load Diff
+1
-1
@@ -30,7 +30,7 @@
|
|||||||
"@aws-sdk/client-secrets-manager": "^3.414.0",
|
"@aws-sdk/client-secrets-manager": "^3.414.0",
|
||||||
"@dadosfera/dadosfera-logs": "^1.0.0-beta.4",
|
"@dadosfera/dadosfera-logs": "^1.0.0-beta.4",
|
||||||
"@dadosfera/protospack": "2.5.3",
|
"@dadosfera/protospack": "2.5.3",
|
||||||
"@dadosfera/protospack-v2": "3.37.0-beta.7",
|
"@dadosfera/protospack-v2": "3.37.0-alpha.19",
|
||||||
"@grpc/grpc-js": "^1.9.3",
|
"@grpc/grpc-js": "^1.9.3",
|
||||||
"@grpc/proto-loader": "^0.7.9",
|
"@grpc/proto-loader": "^0.7.9",
|
||||||
"@nestjs/cli": "^9.5.0",
|
"@nestjs/cli": "^9.5.0",
|
||||||
|
|||||||
@@ -121,6 +121,7 @@ export class AuthenticationGuard
|
|||||||
customer_id: accessTokenPayload.customer_id,
|
customer_id: accessTokenPayload.customer_id,
|
||||||
customer_name: accessTokenPayload.customer_name,
|
customer_name: accessTokenPayload.customer_name,
|
||||||
customer_tier: accessTokenPayload.customer_tier,
|
customer_tier: accessTokenPayload.customer_tier,
|
||||||
|
customer_modules: accessTokenPayload.customer_modules,
|
||||||
access_token: accessToken,
|
access_token: accessToken,
|
||||||
};
|
};
|
||||||
// TODO: for backwards compatibility. remove in the future
|
// TODO: for backwards compatibility. remove in the future
|
||||||
|
|||||||
@@ -609,6 +609,12 @@ export interface DadosferaModule {
|
|||||||
key: string;
|
key: string;
|
||||||
permissionSeqId: number;
|
permissionSeqId: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const DADOSFERA_MODULES_KEYS = {
|
||||||
|
LOG_DASHBOARD: 'logs-dashboard',
|
||||||
|
ACCESS_DASHBOARD: 'access-dashboard'
|
||||||
|
}
|
||||||
|
|
||||||
export const DADOSFERA_MODULES: Array<DadosferaModule> = [
|
export const DADOSFERA_MODULES: Array<DadosferaModule> = [
|
||||||
{
|
{
|
||||||
name: 'Intelligence Module',
|
name: 'Intelligence Module',
|
||||||
|
|||||||
@@ -25,6 +25,14 @@ export function RequireSomePermission(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function RequireModule(
|
||||||
|
key: string
|
||||||
|
) {
|
||||||
|
return createAuthenticatedDecorator((_, user: RequestUser) =>
|
||||||
|
user.customer_modules.some(module => module === key),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
export function AuthenticateCondition(func: AuthenticationFunction) {
|
export function AuthenticateCondition(func: AuthenticationFunction) {
|
||||||
return createAuthenticatedDecorator(func);
|
return createAuthenticatedDecorator(func);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ export interface RequestUser {
|
|||||||
customer_name: string;
|
customer_name: string;
|
||||||
customer_tier: string;
|
customer_tier: string;
|
||||||
access_token: string;
|
access_token: string;
|
||||||
|
customer_modules: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export const User: (options?: { required?: boolean }) => ParameterDecorator =
|
export const User: (options?: { required?: boolean }) => ParameterDecorator =
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ import {
|
|||||||
AuthRefreshAccessTokenRes,
|
AuthRefreshAccessTokenRes,
|
||||||
AuthSignInReq,
|
AuthSignInReq,
|
||||||
AuthSignInRes,
|
AuthSignInRes,
|
||||||
|
BulkEditRequest,
|
||||||
} from './dtos/login';
|
} from './dtos/login';
|
||||||
import { PackTheMetadata } from 'src/utils/ PackTheMetadata';
|
import { PackTheMetadata } from 'src/utils/ PackTheMetadata';
|
||||||
import { AuthGuard } from '@nestjs/passport';
|
import { AuthGuard } from '@nestjs/passport';
|
||||||
@@ -53,6 +54,7 @@ import { LanguageEnum } from 'src/utils/languages.enum';
|
|||||||
import { Language } from 'src/decorators/language.decorator';
|
import { Language } from 'src/decorators/language.decorator';
|
||||||
import { ApiInternalOnlyEndpoint } from 'src/decorators/swagger.decorator';
|
import { ApiInternalOnlyEndpoint } from 'src/decorators/swagger.decorator';
|
||||||
|
|
||||||
|
|
||||||
@ApiTags('Auth')
|
@ApiTags('Auth')
|
||||||
@ApiHeaders([{ name: 'dadosfera-lang', enum: LanguageEnum, required: false }])
|
@ApiHeaders([{ name: 'dadosfera-lang', enum: LanguageEnum, required: false }])
|
||||||
@UseFilters(new GrpcToHttpExceptionFilter())
|
@UseFilters(new GrpcToHttpExceptionFilter())
|
||||||
@@ -61,6 +63,7 @@ export class AuthController {
|
|||||||
logger: DadosferaLogger;
|
logger: DadosferaLogger;
|
||||||
redirectUrl: string;
|
redirectUrl: string;
|
||||||
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@Inject(DadosferaLogger)
|
@Inject(DadosferaLogger)
|
||||||
dadosferaLogger: DadosferaLogger,
|
dadosferaLogger: DadosferaLogger,
|
||||||
@@ -344,4 +347,67 @@ export class AuthController {
|
|||||||
|
|
||||||
return { token, email, url, language };
|
return { token, email, url, language };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiInternalOnlyEndpoint()
|
||||||
|
@Post('users/block')
|
||||||
|
@RequireAllPermissions(PERMISSIONS_GROUPS.USERS.permissions.ADMIN)
|
||||||
|
@HttpCode(HttpStatus.OK)
|
||||||
|
async blockUsers(
|
||||||
|
@Language() language: LanguageEnum,
|
||||||
|
@User() user: RequestUser,
|
||||||
|
@Body() body: BulkEditRequest
|
||||||
|
) {
|
||||||
|
this.logger.info('blockUsers - Starting request');
|
||||||
|
|
||||||
|
try {
|
||||||
|
const metadata = PackTheMetadata(user);
|
||||||
|
|
||||||
|
this.logger.debug('Calling blockUsers service', {
|
||||||
|
metadata: {
|
||||||
|
access_token: metadata.get('access_token'),
|
||||||
|
language: metadata.get('language')
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const result = await this.authClient.blockUsers(body.users, metadata);
|
||||||
|
this.logger.info('blockUsers - Success', { result });
|
||||||
|
return result;
|
||||||
|
} catch (error) {
|
||||||
|
this.logger.error('blockUsers - Error', {
|
||||||
|
error: error.message,
|
||||||
|
stack: error.stack
|
||||||
|
});
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiInternalOnlyEndpoint()
|
||||||
|
@Post('users/unblock')
|
||||||
|
@RequireAllPermissions(PERMISSIONS_GROUPS.USERS.permissions.ADMIN)
|
||||||
|
@HttpCode(HttpStatus.OK)
|
||||||
|
async unblockUsers(
|
||||||
|
@Language() language: LanguageEnum,
|
||||||
|
@User() user: RequestUser,
|
||||||
|
@Body() body: BulkEditRequest
|
||||||
|
) {
|
||||||
|
this.logger.info('unblockUsers');
|
||||||
|
const metadata = PackTheMetadata(user);
|
||||||
|
|
||||||
|
return this.authClient.unblockUsers(body.users, metadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiInternalOnlyEndpoint()
|
||||||
|
@Post('users/reset')
|
||||||
|
@RequireAllPermissions(PERMISSIONS_GROUPS.USERS.permissions.ADMIN)
|
||||||
|
@HttpCode(HttpStatus.OK)
|
||||||
|
async resetUsers(
|
||||||
|
@Language() language: LanguageEnum,
|
||||||
|
@User() user: RequestUser,
|
||||||
|
@Body() body: BulkEditRequest
|
||||||
|
) {
|
||||||
|
this.logger.info('resetUsers');
|
||||||
|
const metadata = PackTheMetadata(user);
|
||||||
|
|
||||||
|
return this.authClient.resetUsers(body.users, metadata);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import {
|
|||||||
} from '@dadosfera/protospack-v2/dist/lib/Duc/interfaces/messages';
|
} from '@dadosfera/protospack-v2/dist/lib/Duc/interfaces/messages';
|
||||||
import { DucClient } from '../duc/client.config';
|
import { DucClient } from '../duc/client.config';
|
||||||
import { Metadata } from '@grpc/grpc-js';
|
import { Metadata } from '@grpc/grpc-js';
|
||||||
|
import { BulkEditResponse } from './dtos/login';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class AuthClientService implements OnModuleInit {
|
export class AuthClientService implements OnModuleInit {
|
||||||
@@ -168,4 +169,63 @@ export class AuthClientService implements OnModuleInit {
|
|||||||
this.authService.AuthOauthSignIn({ token, username, refreshToken: '' }),
|
this.authService.AuthOauthSignIn({ token, username, refreshToken: '' }),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async blockUsers(users: string[],metadata: Metadata): Promise<BulkEditResponse> {
|
||||||
|
this.logger.info('blockUsers - Service starting');
|
||||||
|
|
||||||
|
try {
|
||||||
|
this.logger.debug('Calling BlockUser gRPC method', {
|
||||||
|
metadata: {
|
||||||
|
access_token: metadata.get('access_token'),
|
||||||
|
language: metadata.get('language')
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await lastValueFrom<BulkEditResponse>(
|
||||||
|
this.authService.BlockUser({ users }, metadata),
|
||||||
|
);
|
||||||
|
|
||||||
|
this.logger.info('blockUsers - Service success', { response });
|
||||||
|
return response;
|
||||||
|
} catch (error) {
|
||||||
|
this.logger.error('blockUsers - Service error', {
|
||||||
|
error: error.message,
|
||||||
|
stack: error.stack,
|
||||||
|
});
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async unblockUsers(users: string[],metadata: Metadata): Promise<BulkEditResponse> {
|
||||||
|
this.logger.info('unblockUsers');
|
||||||
|
return await lastValueFrom(
|
||||||
|
this.authService.UnblockUser({ users }, metadata),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
async resetUsers(users: string[], metadata: Metadata): Promise<BulkEditResponse> {
|
||||||
|
this.logger.info('resetUsers');
|
||||||
|
|
||||||
|
try {
|
||||||
|
this.logger.debug('Calling ResetUser gRPC method', {
|
||||||
|
metadata: {
|
||||||
|
access_token: metadata.get('access_token'),
|
||||||
|
language: metadata.get('language')
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await lastValueFrom<BulkEditResponse>(
|
||||||
|
this.authService.ResetUser({ users }, metadata)
|
||||||
|
);
|
||||||
|
|
||||||
|
this.logger.info('resetUsers - Success', { response });
|
||||||
|
return response;
|
||||||
|
} catch (error) {
|
||||||
|
this.logger.error('resetUsers - Error', {
|
||||||
|
error: error.message,
|
||||||
|
stack: error.stack
|
||||||
|
});
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,16 +67,24 @@ export class AuthUser {
|
|||||||
export class AuthCustomer {
|
export class AuthCustomer {
|
||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
modules: string[];
|
modules: string[];
|
||||||
|
|
||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
id: string;
|
id: string;
|
||||||
|
|
||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
name: string;
|
name: string;
|
||||||
|
|
||||||
|
@ApiProperty()
|
||||||
|
displayName: string;
|
||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
tier: string;
|
tier: string;
|
||||||
|
|
||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
scheduleLimit: string;
|
scheduleLimit: string;
|
||||||
|
|
||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
links: Link[];
|
links: Link[];
|
||||||
|
|
||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
themeEnabled: boolean;
|
themeEnabled: boolean;
|
||||||
}
|
}
|
||||||
@@ -120,3 +128,13 @@ export class AuthRefreshAccessTokenRes {
|
|||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
accessToken: string;
|
accessToken: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface BulkEditRequest {
|
||||||
|
users: string[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface BulkEditResponse {
|
||||||
|
message: string;
|
||||||
|
successfulUsers: string[];
|
||||||
|
failedUsers: string[];
|
||||||
|
}
|
||||||
|
|||||||
@@ -12,10 +12,11 @@ import {
|
|||||||
UseFilters,
|
UseFilters,
|
||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
import { ApiOkResponse, ApiProduces, ApiTags } from '@nestjs/swagger';
|
import { ApiOkResponse, ApiProduces, ApiTags } from '@nestjs/swagger';
|
||||||
import { PERMISSIONS_GROUPS } from 'src/authentication/permissions.enum';
|
import { DADOSFERA_MODULES_KEYS, PERMISSIONS_GROUPS } from 'src/authentication/permissions.enum';
|
||||||
import {
|
import {
|
||||||
Authenticated,
|
Authenticated,
|
||||||
RequireAllPermissions,
|
RequireAllPermissions,
|
||||||
|
RequireModule,
|
||||||
} from 'src/decorators/authentication.decorator';
|
} from 'src/decorators/authentication.decorator';
|
||||||
import { GrpcToHttpExceptionFilter } from 'src/error/grpc-to-http-exception.filter';
|
import { GrpcToHttpExceptionFilter } from 'src/error/grpc-to-http-exception.filter';
|
||||||
import { CustomersService } from './customers.service';
|
import { CustomersService } from './customers.service';
|
||||||
@@ -91,4 +92,36 @@ export class CustomersController {
|
|||||||
const metadata = PackTheMetadata(user);
|
const metadata = PackTheMetadata(user);
|
||||||
return this.customersService.getMonitoringDashboardUrl(metadata);
|
return this.customersService.getMonitoringDashboardUrl(metadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Get('logs-dashboard')
|
||||||
|
@Authenticated()
|
||||||
|
@RequireAllPermissions(
|
||||||
|
PERMISSIONS_GROUPS.USERS.permissions.ADMIN,
|
||||||
|
)
|
||||||
|
@RequireModule(DADOSFERA_MODULES_KEYS.LOG_DASHBOARD)
|
||||||
|
async getCustomerMixPanelLogsDashboard(
|
||||||
|
@User() user: RequestUser,
|
||||||
|
): Promise<{ url: string }> {
|
||||||
|
this.logger.info('getLogsDashboardUrl');
|
||||||
|
const metadata = PackTheMetadata(user);
|
||||||
|
|
||||||
|
const result = await this.customersService.getLogsDashboardUrl(metadata);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get('access-dashboard')
|
||||||
|
@Authenticated()
|
||||||
|
@RequireAllPermissions(
|
||||||
|
PERMISSIONS_GROUPS.USERS.permissions.ADMIN,
|
||||||
|
)
|
||||||
|
@RequireModule(DADOSFERA_MODULES_KEYS.ACCESS_DASHBOARD)
|
||||||
|
async getAccessDashboard(
|
||||||
|
@User() user: RequestUser,
|
||||||
|
): Promise<{ url: string }> {
|
||||||
|
this.logger.info('getAccessDashboard');
|
||||||
|
const metadata = PackTheMetadata(user);
|
||||||
|
|
||||||
|
const result = await this.customersService.getAccessDashboardUrl(user.customer_name, metadata);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import {
|
|||||||
HttpException,
|
HttpException,
|
||||||
HttpStatus,
|
HttpStatus,
|
||||||
InternalServerErrorException,
|
InternalServerErrorException,
|
||||||
|
ForbiddenException,
|
||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
|
|
||||||
import { firstValueFrom, lastValueFrom } from 'rxjs';
|
import { firstValueFrom, lastValueFrom } from 'rxjs';
|
||||||
@@ -145,7 +146,7 @@ export class CustomersService implements OnModuleInit {
|
|||||||
const res = await lastValueFrom(
|
const res = await lastValueFrom(
|
||||||
this.pipelineReadService.PipelineV2GetDashboardUrl(
|
this.pipelineReadService.PipelineV2GetDashboardUrl(
|
||||||
{
|
{
|
||||||
dashboard_id: '45',
|
dashboard_id: '98',
|
||||||
exp: '15m',
|
exp: '15m',
|
||||||
metabase_customer_name: 'dadosferatech',
|
metabase_customer_name: 'dadosferatech',
|
||||||
},
|
},
|
||||||
@@ -156,4 +157,50 @@ export class CustomersService implements OnModuleInit {
|
|||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
async getLogsDashboardUrl(metadata: Metadata) {
|
||||||
|
logger.info('CustomersService - getMixPanelLogsDashboardUrl');
|
||||||
|
|
||||||
|
const res = await lastValueFrom(
|
||||||
|
this.pipelineReadService.PipelineV2GetDashboardUrl(
|
||||||
|
{
|
||||||
|
dashboard_id: '103',
|
||||||
|
exp: '15m',
|
||||||
|
metabase_customer_name: 'dadosferatech',
|
||||||
|
},
|
||||||
|
metadata,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
logger.info('Done');
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
async getAccessDashboardUrl(customerName: string, metadata: Metadata) {
|
||||||
|
/*
|
||||||
|
* TODO(Refactor): dar um jeito de exibir o dash da sbm diferente dos outros customer
|
||||||
|
* pois o signicado de department para sbm significa as instituições do usuários
|
||||||
|
*/
|
||||||
|
if (customerName !== 'sbmoffshorecom') {
|
||||||
|
throw new ForbiddenException();
|
||||||
|
}
|
||||||
|
logger.info('CustomersService - getAccessDashboardUrl');
|
||||||
|
|
||||||
|
const res = await this.getDashboardUrl('105', metadata);
|
||||||
|
logger.info('Done');
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async getDashboardUrl(dashboardId: string, metadata: Metadata) {
|
||||||
|
return await lastValueFrom(
|
||||||
|
this.pipelineReadService.PipelineV2GetDashboardUrl(
|
||||||
|
{
|
||||||
|
dashboard_id: dashboardId,
|
||||||
|
exp: '15m',
|
||||||
|
metabase_customer_name: 'dadosferatech',
|
||||||
|
},
|
||||||
|
metadata
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Body, Controller, Inject, Param, Post } from '@nestjs/common';
|
import { Body, Controller, Inject, Param, Post, Req } from '@nestjs/common';
|
||||||
import { init } from 'mixpanel';
|
import { init } from 'mixpanel';
|
||||||
import { Authenticated } from 'src/decorators/authentication.decorator';
|
import { Authenticated } from 'src/decorators/authentication.decorator';
|
||||||
import { ApiInternalOnlyController } from 'src/decorators/swagger.decorator';
|
import { ApiInternalOnlyController } from 'src/decorators/swagger.decorator';
|
||||||
@@ -13,7 +13,12 @@ export class MixpanelController {
|
|||||||
private readonly mixpanelToken: string,
|
private readonly mixpanelToken: string,
|
||||||
) {}
|
) {}
|
||||||
@Post(':id')
|
@Post(':id')
|
||||||
async trackEvent(@Param('id') id, @Body() body, @User() user: RequestUser) {
|
async trackEvent(
|
||||||
|
@Param('id') id,
|
||||||
|
@Body() body,
|
||||||
|
@User() user: RequestUser,
|
||||||
|
@Req() request
|
||||||
|
) {
|
||||||
delete body.info;
|
delete body.info;
|
||||||
const mixpanel = init(this.mixpanelToken);
|
const mixpanel = init(this.mixpanelToken);
|
||||||
|
|
||||||
@@ -66,13 +71,16 @@ export class MixpanelController {
|
|||||||
$email: user.username.includes('@')
|
$email: user.username.includes('@')
|
||||||
? user.username
|
? user.username
|
||||||
: user.username + '@dadosfera.ai',
|
: user.username + '@dadosfera.ai',
|
||||||
customer_name: user.customer_name,
|
customer_name: user.customer_name
|
||||||
});
|
});
|
||||||
|
|
||||||
await mixpanel.track(id, {
|
await mixpanel.track(id, {
|
||||||
distinct_id: user.username,
|
distinct_id: user.username,
|
||||||
customer: user.customer_name,
|
customer: user.customer_name,
|
||||||
env: process.env.ENV,
|
env: process.env.ENV,
|
||||||
|
$ip: request.ip,
|
||||||
|
$os: request.headers['sec-ch-ua-platform'] || '',
|
||||||
|
$browser: request.headers['user-agent'],
|
||||||
...body,
|
...body,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import DadosferaLogger from '@dadosfera/dadosfera-logs';
|
import DadosferaLogger from '@dadosfera/dadosfera-logs';
|
||||||
import { Body, Controller, ForbiddenException, Header, HttpCode, Inject, Param, Post, Query, Req, UseFilters, UseGuards, UseInterceptors } from '@nestjs/common';
|
import { Body, Controller, ForbiddenException, Header, Headers, HttpCode, HttpException, Inject, Param, Post, Query, Req, Res, UseFilters, UseGuards, UseInterceptors } from '@nestjs/common';
|
||||||
import { ApiCreatedResponse, ApiHeaders, ApiOkResponse, ApiTags } from '@nestjs/swagger';
|
import { ApiCreatedResponse, ApiHeaders, ApiOkResponse, ApiTags } from '@nestjs/swagger';
|
||||||
import { ApiInternalOnlyController } from 'src/decorators/swagger.decorator';
|
import { ApiInternalOnlyController } from 'src/decorators/swagger.decorator';
|
||||||
import { GrpcToHttpExceptionFilter } from 'src/error/grpc-to-http-exception.filter';
|
import { GrpcToHttpExceptionFilter } from 'src/error/grpc-to-http-exception.filter';
|
||||||
@@ -40,17 +40,23 @@ export class OpenDataController {
|
|||||||
language: string,
|
language: string,
|
||||||
@Req()
|
@Req()
|
||||||
request: Request,
|
request: Request,
|
||||||
|
@Headers('origin')
|
||||||
|
origin: string
|
||||||
) {
|
) {
|
||||||
this.logger.info('createUser for open data');
|
this.logger.info('createUser for open data' + JSON.stringify(request.headers));
|
||||||
|
|
||||||
this.logger.info('user-agent', request.headers['user-agent']);
|
const corslist = ["https://devsbm.dadosfera.io", "https://sharingoceandata.com"];
|
||||||
|
if (!corslist.includes(origin)) {
|
||||||
|
this.logger.info('block request by cors list: '+ origin);
|
||||||
|
throw new ForbiddenException();
|
||||||
|
}
|
||||||
|
|
||||||
const OPENDATA_CUSTOMER_ID = process.env.OPEN_CUSTOMER_ID;
|
const OPENDATA_CUSTOMER_ID = process.env.OPEN_CUSTOMER_ID;
|
||||||
const OPENDATA_GROUP_ID = process.env.OPEN_GROUP_ID;
|
const OPENDATA_GROUP_ID = process.env.OPEN_GROUP_ID;
|
||||||
const roles = [process.env.OPEN_GROUP_ID];
|
const roles = [process.env.OPEN_GROUP_ID];
|
||||||
const metadata = PackTheMetadata({
|
const metadata = PackTheMetadata({
|
||||||
language: language || 'en-us'
|
language: language || 'en-us'
|
||||||
});
|
});
|
||||||
|
|
||||||
const data = {}
|
const data = {}
|
||||||
|
|
||||||
|
|||||||
@@ -77,6 +77,13 @@ export function EnrichErrorCode(code: string) {
|
|||||||
message: 'Token para recuperar senha inválido',
|
message: 'Token para recuperar senha inválido',
|
||||||
code,
|
code,
|
||||||
};
|
};
|
||||||
|
case ErrorCodes.AUTH.REQUIRED_PASSWORD_RESET:
|
||||||
|
return {
|
||||||
|
statusCode: HttpStatus.UNAUTHORIZED,
|
||||||
|
error: 'Não permitido',
|
||||||
|
message: 'Seu usuário foi resetado por um administrador, resete a senha pelo link "Esqueci a senha", para prosseguir',
|
||||||
|
code,
|
||||||
|
};
|
||||||
|
|
||||||
case ErrorCodes.AUTH.WEAK_NEW_PASSWORD:
|
case ErrorCodes.AUTH.WEAK_NEW_PASSWORD:
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ export const AUTH = {
|
|||||||
RESET_PASSWORD_CODE_EXPIRED: 'AUTH.RESET_PASSWORD_CODE_EXPIRED',
|
RESET_PASSWORD_CODE_EXPIRED: 'AUTH.RESET_PASSWORD_CODE_EXPIRED',
|
||||||
RESET_PASSWORD_CODE_INVALID: 'AUTH.RESET_PASSWORD_CODE_INVALID',
|
RESET_PASSWORD_CODE_INVALID: 'AUTH.RESET_PASSWORD_CODE_INVALID',
|
||||||
WEAK_NEW_PASSWORD: 'AUTH.WEAK_NEW_PASSWORD',
|
WEAK_NEW_PASSWORD: 'AUTH.WEAK_NEW_PASSWORD',
|
||||||
|
REQUIRED_PASSWORD_RESET: 'AUTH.REQUIRED_PASSWORD_RESET'
|
||||||
};
|
};
|
||||||
export const ROLE = {
|
export const ROLE = {
|
||||||
INVALID_ID: 'ROLE.INVALID_ID',
|
INVALID_ID: 'ROLE.INVALID_ID',
|
||||||
|
|||||||
Reference in New Issue
Block a user