From e47459eb9aec205544b59d3708e18fbb577357f8 Mon Sep 17 00:00:00 2001 From: Victor Radael Date: Thu, 15 Dec 2022 16:00:54 -0300 Subject: [PATCH 1/4] FEAT: Edit connection --- src/modules/connection/connection.controller.ts | 7 ++++++- src/utils/ PackTheMetadata.ts | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/modules/connection/connection.controller.ts b/src/modules/connection/connection.controller.ts index a0dfdfe..2aa47cf 100644 --- a/src/modules/connection/connection.controller.ts +++ b/src/modules/connection/connection.controller.ts @@ -164,11 +164,15 @@ export class ConnectionController { @Headers('Dadosfera-Lang') language, @User() user: RequestUser, @Param('id') id, - @Query('details') details, + @Query() queries, ): Promise { this.logger.info('/connections - Get Connection Details'); if (!language) language = 'en-us'; + console.log(queries); + + const { details, sensitive } = queries; + const { user_id, customer_id, customer_name, username } = user; const metadata = PackTheMetadata({ user_id, @@ -177,6 +181,7 @@ export class ConnectionController { username, details, language, + sensitive, }); const response: any = await this.clientService.getConnectionDetails({ diff --git a/src/utils/ PackTheMetadata.ts b/src/utils/ PackTheMetadata.ts index 35037b6..a6aaddc 100644 --- a/src/utils/ PackTheMetadata.ts +++ b/src/utils/ PackTheMetadata.ts @@ -7,6 +7,7 @@ interface IMetadata { user_id?: string; language?: string; details?: string; + sensitive?: string; roles?: string[]; is_data_manager?: boolean; } From cda7f9a9b5dc24df3fff37ea6c405ffbac6703d6 Mon Sep 17 00:00:00 2001 From: Victor Radael Date: Thu, 15 Dec 2022 16:01:24 -0300 Subject: [PATCH 2/4] FEAT: Edit connection --- docsfera.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docsfera.json b/docsfera.json index c8315f3..8a386a4 100644 --- a/docsfera.json +++ b/docsfera.json @@ -3287,7 +3287,7 @@ } }, "info": { - "title": "Maestro - feat/cognito-app-client", + "title": "Maestro - feat/upload-csv", "description": "Documentation for Maestro gateway", "version": "1.0.0", "contact": {} From c5c428d3d45409afe71613c80743facd1483c0f4 Mon Sep 17 00:00:00 2001 From: Victor Radael Date: Thu, 15 Dec 2022 19:57:52 -0300 Subject: [PATCH 3/4] FIX: Refresh token --- docsfera.json | 2 +- src/modules/auth/auth.controller.ts | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/docsfera.json b/docsfera.json index 8a386a4..0701ee4 100644 --- a/docsfera.json +++ b/docsfera.json @@ -3287,7 +3287,7 @@ } }, "info": { - "title": "Maestro - feat/upload-csv", + "title": "Maestro - feat/update-connection", "description": "Documentation for Maestro gateway", "version": "1.0.0", "contact": {} diff --git a/src/modules/auth/auth.controller.ts b/src/modules/auth/auth.controller.ts index 4c2fbf9..2c85de5 100644 --- a/src/modules/auth/auth.controller.ts +++ b/src/modules/auth/auth.controller.ts @@ -32,6 +32,7 @@ import { GrpcToHttpExceptionFilter } from '../../error/grpc-to-http-exception.fi import { RequestUser, User } from 'src/authentication/user.decorator'; import { Metadata } from '@grpc/grpc-js'; import { AuthSignInReq, AuthSignInRes } from './dtos/login'; +import { PackTheMetadata } from 'src/utils/ PackTheMetadata'; @ApiTags('Auth') @UseFilters(new GrpcToHttpExceptionFilter()) @@ -82,9 +83,11 @@ export class AuthController { @User() user: RequestUser, ) { this.logger.info('/auth - RefreshAccessToken'); - const metadata = new Metadata(); - metadata.add('language', language || 'pt-br'); - metadata.add('customer_name', user.customer_name); + + const metadata = PackTheMetadata({ + customer_name: user.customer_name, + language, + }); return this.authClient.refreshAccessToken({ refreshToken }, metadata); } From 59c3ce7ed96f489b82e572d8384007cf784ab43c Mon Sep 17 00:00:00 2001 From: Gabriel Rosa Date: Fri, 16 Dec 2022 08:09:20 -0300 Subject: [PATCH 4/4] FIX: do not use User() on non-authenticated routes --- docsfera.json | 27 ++++++++++++++++++++++++++- src/modules/auth/auth.controller.ts | 13 ++++++++----- src/modules/auth/dtos/login.ts | 7 +++++++ 3 files changed, 41 insertions(+), 6 deletions(-) diff --git a/docsfera.json b/docsfera.json index 0701ee4..fef3b5a 100644 --- a/docsfera.json +++ b/docsfera.json @@ -79,6 +79,16 @@ } } ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AuthRefreshAccessTokenReq" + } + } + } + }, "responses": { "200": { "description": "", @@ -3287,7 +3297,7 @@ } }, "info": { - "title": "Maestro - feat/update-connection", + "title": "Maestro - fix/refresh-token", "description": "Documentation for Maestro gateway", "version": "1.0.0", "contact": {} @@ -3473,6 +3483,21 @@ "mfaStatus" ] }, + "AuthRefreshAccessTokenReq": { + "type": "object", + "properties": { + "refreshToken": { + "type": "string" + }, + "customerName": { + "type": "string" + } + }, + "required": [ + "refreshToken", + "customerName" + ] + }, "CreateConnectorDto": { "type": "object", "properties": { diff --git a/src/modules/auth/auth.controller.ts b/src/modules/auth/auth.controller.ts index 2c85de5..16a9a52 100644 --- a/src/modules/auth/auth.controller.ts +++ b/src/modules/auth/auth.controller.ts @@ -11,7 +11,6 @@ import { } from '@nestjs/common'; import { ApiTags } from '@nestjs/swagger'; import { - AuthRefreshAccessTokenRequest, AuthChangePasswordRequest, AuthResetPasswordRequest, AuthVerifyResetPasswordCodeRequest, @@ -31,7 +30,11 @@ import { DadosferaLogger } from '@dadosfera/dadosfera-logs'; import { GrpcToHttpExceptionFilter } from '../../error/grpc-to-http-exception.filter'; import { RequestUser, User } from 'src/authentication/user.decorator'; import { Metadata } from '@grpc/grpc-js'; -import { AuthSignInReq, AuthSignInRes } from './dtos/login'; +import { + AuthRefreshAccessTokenReq, + AuthSignInReq, + AuthSignInRes, +} from './dtos/login'; import { PackTheMetadata } from 'src/utils/ PackTheMetadata'; @ApiTags('Auth') @@ -78,14 +81,14 @@ export class AuthController { @Post('refresh-access-token') @HttpCode(HttpStatus.OK) async refreshAccessToken( - @Body() { refreshToken }: AuthRefreshAccessTokenRequest, + @Body() + { refreshToken, customerName: customer_name }: AuthRefreshAccessTokenReq, @Headers('Dadosfera-Lang') language: string, - @User() user: RequestUser, ) { this.logger.info('/auth - RefreshAccessToken'); const metadata = PackTheMetadata({ - customer_name: user.customer_name, + customer_name, language, }); diff --git a/src/modules/auth/dtos/login.ts b/src/modules/auth/dtos/login.ts index 32e1885..1c9b1a3 100644 --- a/src/modules/auth/dtos/login.ts +++ b/src/modules/auth/dtos/login.ts @@ -97,3 +97,10 @@ export class AuthSignInRes implements AuthSignInResponse { @ApiPropertyOptional() termsOfUse?: TermsOfUseStatus; } + +export class AuthRefreshAccessTokenReq { + @ApiProperty() + refreshToken: string; + @ApiProperty() + customerName: string; +}