Compare commits

...
5 changed files with 29 additions and 13 deletions
+8
View File
@@ -5489,6 +5489,14 @@
"schema": { "schema": {
"type": "string" "type": "string"
} }
},
{
"name": "origin",
"required": true,
"in": "header",
"schema": {
"type": "string"
}
} }
], ],
"responses": { "responses": {
+3 -3
View File
@@ -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
+2 -2
View File
@@ -2,7 +2,7 @@ apiVersion: networking.k8s.io/v1
kind: Ingress kind: Ingress
metadata: metadata:
annotations: annotations:
nginx.ingress.kubernetes.io/whitelist-source-range: "69.49.241.124/32" # hostgator ip 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/proxy-body-size: "0"
nginx.ingress.kubernetes.io/server-snippet: | nginx.ingress.kubernetes.io/server-snippet: |
underscores_in_headers on; underscores_in_headers on;
@@ -11,7 +11,7 @@ metadata:
generation: 1 generation: 1
labels: labels:
app: maestro app: maestro
name: maestro name: open-data
namespace: applications namespace: applications
spec: spec:
ingressClassName: nginx ingressClassName: nginx
+11 -3
View File
@@ -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, HttpException, 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,14 +40,14 @@ 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);
const origin = request.headers['origin'];
const corslist = ["https://devsbm.dadosfera.io", "https://sharingoceandata.com"]; const corslist = ["https://devsbm.dadosfera.io", "https://sharingoceandata.com"];
if (!corslist.includes(origin)) { if (!corslist.includes(origin)) {
this.logger.info('block request by cors list: '+ origin);
throw new ForbiddenException(); throw new ForbiddenException();
} }