From cd4382c1ffe63f138be4e17bdda6b11245e88cee Mon Sep 17 00:00:00 2001 From: marcos-silva-rodrigues Date: Mon, 2 Feb 2026 15:37:13 -0300 Subject: [PATCH] FIX: send token by storage --- docsfera.json | 156 +++++++++++++++++- .../storage-explorer.controller.ts | 38 ++++- .../storage-explorer.service.ts | 4 +- 3 files changed, 192 insertions(+), 6 deletions(-) diff --git a/docsfera.json b/docsfera.json index 801658d..04853e7 100644 --- a/docsfera.json +++ b/docsfera.json @@ -7865,7 +7865,16 @@ "post": { "operationId": "StorageExplorerController_validateTableName", "summary": "Validate table name in PostgreSQL and Snowflake", - "parameters": [], + "parameters": [ + { + "name": "Authorization", + "required": true, + "in": "header", + "schema": { + "type": "string" + } + } + ], "responses": { "201": { "description": "", @@ -7895,7 +7904,16 @@ "post": { "operationId": "StorageExplorerController_createTable", "summary": "Create a new table", - "parameters": [], + "parameters": [ + { + "name": "Authorization", + "required": true, + "in": "header", + "schema": { + "type": "string" + } + } + ], "responses": { "201": { "description": "", @@ -7931,6 +7949,14 @@ "schema": { "type": "number" } + }, + { + "name": "Authorization", + "required": true, + "in": "header", + "schema": { + "type": "string" + } } ], "responses": { @@ -7970,6 +7996,14 @@ "schema": { "type": "string" } + }, + { + "name": "Authorization", + "required": true, + "in": "header", + "schema": { + "type": "string" + } } ], "responses": { @@ -8017,6 +8051,14 @@ "schema": { "type": "string" } + }, + { + "name": "Authorization", + "required": true, + "in": "header", + "schema": { + "type": "string" + } } ], "responses": { @@ -8056,6 +8098,14 @@ "schema": { "type": "string" } + }, + { + "name": "Authorization", + "required": true, + "in": "header", + "schema": { + "type": "string" + } } ], "responses": { @@ -8095,6 +8145,14 @@ "schema": { "type": "string" } + }, + { + "name": "Authorization", + "required": true, + "in": "header", + "schema": { + "type": "string" + } } ], "responses": { @@ -8142,6 +8200,14 @@ "schema": { "type": "string" } + }, + { + "name": "Authorization", + "required": true, + "in": "header", + "schema": { + "type": "string" + } } ], "responses": { @@ -8189,6 +8255,14 @@ "schema": { "type": "number" } + }, + { + "name": "Authorization", + "required": true, + "in": "header", + "schema": { + "type": "string" + } } ], "responses": { @@ -8236,6 +8310,14 @@ "schema": { "type": "boolean" } + }, + { + "name": "Authorization", + "required": true, + "in": "header", + "schema": { + "type": "string" + } } ], "responses": { @@ -8275,6 +8357,14 @@ "schema": { "type": "string" } + }, + { + "name": "Authorization", + "required": true, + "in": "header", + "schema": { + "type": "string" + } } ], "responses": { @@ -8314,6 +8404,14 @@ "schema": { "type": "string" } + }, + { + "name": "Authorization", + "required": true, + "in": "header", + "schema": { + "type": "string" + } } ], "responses": { @@ -8369,6 +8467,14 @@ "schema": { "type": "string" } + }, + { + "name": "Authorization", + "required": true, + "in": "header", + "schema": { + "type": "string" + } } ], "responses": { @@ -8408,6 +8514,14 @@ "schema": { "type": "string" } + }, + { + "name": "Authorization", + "required": true, + "in": "header", + "schema": { + "type": "string" + } } ], "responses": { @@ -8439,7 +8553,16 @@ "post": { "operationId": "StorageExplorerController_batchUpload", "summary": "Upload multiple files to storage", - "parameters": [], + "parameters": [ + { + "name": "Authorization", + "required": true, + "in": "header", + "schema": { + "type": "string" + } + } + ], "responses": { "201": { "description": "", @@ -8469,7 +8592,16 @@ "post": { "operationId": "StorageExplorerController_createFolder", "summary": "Create a new folder in storage", - "parameters": [], + "parameters": [ + { + "name": "Authorization", + "required": true, + "in": "header", + "schema": { + "type": "string" + } + } + ], "responses": { "201": { "description": "", @@ -8507,6 +8639,14 @@ "schema": { "type": "string" } + }, + { + "name": "Authorization", + "required": true, + "in": "header", + "schema": { + "type": "string" + } } ], "responses": { @@ -8546,6 +8686,14 @@ "schema": { "type": "string" } + }, + { + "name": "Authorization", + "required": true, + "in": "header", + "schema": { + "type": "string" + } } ], "responses": { diff --git a/src/modules/storage-explorer/storage-explorer.controller.ts b/src/modules/storage-explorer/storage-explorer.controller.ts index ef6a071..50dcc96 100644 --- a/src/modules/storage-explorer/storage-explorer.controller.ts +++ b/src/modules/storage-explorer/storage-explorer.controller.ts @@ -3,13 +3,13 @@ import { Get, Post, Put, - Delete, Param, Body, Query, Inject, UseInterceptors, UploadedFiles, + Headers, } from '@nestjs/common'; import { ApiTags, ApiOperation, ApiConsumes } from '@nestjs/swagger'; import { FilesInterceptor } from '@nestjs/platform-express'; @@ -47,11 +47,13 @@ export class StorageExplorerController { async validateTableName( @Body() body: any, @User() user: RequestUser, + @Headers('Authorization') token: string ) { return this.storageExplorerService.proxy( 'POST', '/tables/validate-name', user, + token, body, ); } @@ -62,11 +64,13 @@ export class StorageExplorerController { async createTable( @Body() body: any, @User() user: RequestUser, + @Headers('Authorization') token: string ) { return this.storageExplorerService.proxy( 'POST', '/tables/', user, + token, body, ); } @@ -77,11 +81,13 @@ export class StorageExplorerController { async listTables( @Query('page') page: number, @User() user: RequestUser, + @Headers('Authorization') token: string ) { return this.storageExplorerService.proxy( 'GET', '/tables/', user, + token, undefined, { page }, ); @@ -93,11 +99,13 @@ export class StorageExplorerController { async getTable( @Param('tableId') tableId: string, @User() user: RequestUser, + @Headers('Authorization') token: string ) { return this.storageExplorerService.proxy( 'GET', `/tables/${tableId}`, user, + token ); } @@ -108,11 +116,13 @@ export class StorageExplorerController { @Param('tableId') tableId: string, @Param('datasetId') datasetId: string, @User() user: RequestUser, + @Headers('Authorization') token: string ) { return this.storageExplorerService.proxy( 'POST', `/tables/${tableId}/datasets/${datasetId}`, user, + token ); } @@ -122,11 +132,13 @@ export class StorageExplorerController { async getTableDatasets( @Param('tableId') tableId: string, @User() user: RequestUser, + @Headers('Authorization') token: string ) { return this.storageExplorerService.proxy( 'GET', `/tables/${tableId}/datasets`, user, + token ); } @@ -136,11 +148,13 @@ export class StorageExplorerController { async getTableSchema( @Param('tableId') tableId: string, @User() user: RequestUser, + @Headers('Authorization') token: string ) { return this.storageExplorerService.proxy( 'GET', `/tables/${tableId}/schema`, user, + token ); } @@ -151,11 +165,13 @@ export class StorageExplorerController { @Param('tableId') tableId: string, @Param('datasetId') datasetId: string, @User() user: RequestUser, + @Headers('Authorization') token: string ) { return this.storageExplorerService.proxy( 'POST', `/tables/${tableId}/validate-compatibility/${datasetId}`, user, + token ); } @@ -170,11 +186,13 @@ export class StorageExplorerController { @Param('datasetId') datasetId: string, @Query('limit') limit: number, @User() user: RequestUser, + @Headers('Authorization') token: string ) { return this.storageExplorerService.proxy( 'GET', `/datasets/${datasetId}/preview`, user, + token, undefined, { limit }, ); @@ -187,11 +205,13 @@ export class StorageExplorerController { @Param('datasetId') datasetId: string, @Query('force_refresh') forceRefresh: boolean, @User() user: RequestUser, + @Headers('Authorization') token: string ) { return this.storageExplorerService.proxy( 'GET', `/datasets/${datasetId}/schema`, user, + token, undefined, { force_refresh: forceRefresh }, ); @@ -203,11 +223,13 @@ export class StorageExplorerController { async listDatasetsByUpload( @Param('uploadId') uploadId: string, @User() user: RequestUser, + @Headers('Authorization') token: string ) { return this.storageExplorerService.proxy( 'GET', `/datasets/upload/${uploadId}`, user, + token ); } @@ -218,11 +240,13 @@ export class StorageExplorerController { @Param('datasetId') datasetId: string, @Body() body: any, @User() user: RequestUser, + @Headers('Authorization') token: string ) { return this.storageExplorerService.proxy( 'PUT', `/datasets/${datasetId}/refresh-schema`, user, + token, body, ); } @@ -239,11 +263,13 @@ export class StorageExplorerController { @Query('limit') limit: number, @Query('folder_path') folderPath: string, @User() user: RequestUser, + @Headers('Authorization') token: string ) { return this.storageExplorerService.proxy( 'GET', '/storage/uploads/history', user, + token, undefined, { page, limit, folder_path: folderPath }, ); @@ -255,11 +281,13 @@ export class StorageExplorerController { async browseStorage( @Query('path') path: string, @User() user: RequestUser, + @Headers('Authorization') token: string ) { return this.storageExplorerService.proxy( 'GET', '/storage/browse', user, + token, undefined, { path }, ); @@ -274,6 +302,7 @@ export class StorageExplorerController { @UploadedFiles() files: Array, @Body('folder_path') folderPath: string, @User() user: RequestUser, + @Headers('Authorization') token: string ) { // Create FormData to forward files to storage-explorer API const formData = new FormData(); @@ -297,6 +326,7 @@ export class StorageExplorerController { 'POST', '/storage/upload/batch', user, + token, formData, ); } @@ -307,11 +337,13 @@ export class StorageExplorerController { async createFolder( @Body() body: any, @User() user: RequestUser, + @Headers('Authorization') token: string ) { return this.storageExplorerService.proxy( 'POST', '/storage/folder/create', user, + token, body, ); } @@ -322,11 +354,13 @@ export class StorageExplorerController { async downloadFile( @Query('file_path') filePath: string, @User() user: RequestUser, + @Headers('Authorization') token: string ) { return this.storageExplorerService.proxy( 'GET', '/storage/download', user, + token, undefined, { file_path: filePath }, ); @@ -338,11 +372,13 @@ export class StorageExplorerController { async getFileMetadata( @Query('file_path') filePath: string, @User() user: RequestUser, + @Headers('Authorization') token: string ) { return this.storageExplorerService.proxy( 'GET', '/storage/metadata', user, + token, undefined, { file_path: filePath }, ); diff --git a/src/modules/storage-explorer/storage-explorer.service.ts b/src/modules/storage-explorer/storage-explorer.service.ts index 5ff3bf7..c7de628 100644 --- a/src/modules/storage-explorer/storage-explorer.service.ts +++ b/src/modules/storage-explorer/storage-explorer.service.ts @@ -19,8 +19,9 @@ export class StorageExplorerService { method: string, path: string, user: RequestUser, + token: string, body?: any, - query?: Record, + query?: Record ): Promise { // Validate customer_id is present for multi-tenant isolation if (!user.customer_id) { @@ -41,6 +42,7 @@ export class StorageExplorerService { } const headers: Record = { + 'Authorization': token, 'content-type': 'application/json', };