Compare commits

..
Author SHA1 Message Date
Marcos Rodrigues Silva e08734c97f Merge pull request #439 from dadosfera/fix/proxy-urls
FIX: send token by storage
2026-02-02 15:39:00 -03:00
Marcos Rodrigues Silva 54b75ce11b Merge pull request #438 from dadosfera/fix/proxy-urls
FIX: storage api
2026-02-02 14:43:00 -03:00
Marcos Rodrigues Silva 85234fe0dd Merge pull request #437 from dadosfera/fix/proxy-urls
Fix/proxy urls
2026-02-02 14:28:04 -03:00
6 changed files with 194 additions and 41 deletions
+1 -1
View File
@@ -9,7 +9,7 @@ maestro:
cookie_secret: "ff7bc13823edb2ae50d248e5780bddc9d4b31c36" cookie_secret: "ff7bc13823edb2ae50d248e5780bddc9d4b31c36"
redis_database: "1" redis_database: "1"
platform_api_url: https://xs2hkhq07k.execute-api.us-east-1.amazonaws.com platform_api_url: https://xs2hkhq07k.execute-api.us-east-1.amazonaws.com
storage_explorer_api_url: "http://storage-explorer-{customer}.data-apps.svc.cluster.local:8000/api" storage_explorer_api_url: "https://storage-explorer-{customer}.stg.dadosfera.ai/api"
hostname: maestro.stg.dadosfera.ai hostname: maestro.stg.dadosfera.ai
+152 -4
View File
@@ -7865,7 +7865,16 @@
"post": { "post": {
"operationId": "StorageExplorerController_validateTableName", "operationId": "StorageExplorerController_validateTableName",
"summary": "Validate table name in PostgreSQL and Snowflake", "summary": "Validate table name in PostgreSQL and Snowflake",
"parameters": [], "parameters": [
{
"name": "Authorization",
"required": true,
"in": "header",
"schema": {
"type": "string"
}
}
],
"responses": { "responses": {
"201": { "201": {
"description": "", "description": "",
@@ -7895,7 +7904,16 @@
"post": { "post": {
"operationId": "StorageExplorerController_createTable", "operationId": "StorageExplorerController_createTable",
"summary": "Create a new table", "summary": "Create a new table",
"parameters": [], "parameters": [
{
"name": "Authorization",
"required": true,
"in": "header",
"schema": {
"type": "string"
}
}
],
"responses": { "responses": {
"201": { "201": {
"description": "", "description": "",
@@ -7931,6 +7949,14 @@
"schema": { "schema": {
"type": "number" "type": "number"
} }
},
{
"name": "Authorization",
"required": true,
"in": "header",
"schema": {
"type": "string"
}
} }
], ],
"responses": { "responses": {
@@ -7970,6 +7996,14 @@
"schema": { "schema": {
"type": "string" "type": "string"
} }
},
{
"name": "Authorization",
"required": true,
"in": "header",
"schema": {
"type": "string"
}
} }
], ],
"responses": { "responses": {
@@ -8017,6 +8051,14 @@
"schema": { "schema": {
"type": "string" "type": "string"
} }
},
{
"name": "Authorization",
"required": true,
"in": "header",
"schema": {
"type": "string"
}
} }
], ],
"responses": { "responses": {
@@ -8056,6 +8098,14 @@
"schema": { "schema": {
"type": "string" "type": "string"
} }
},
{
"name": "Authorization",
"required": true,
"in": "header",
"schema": {
"type": "string"
}
} }
], ],
"responses": { "responses": {
@@ -8095,6 +8145,14 @@
"schema": { "schema": {
"type": "string" "type": "string"
} }
},
{
"name": "Authorization",
"required": true,
"in": "header",
"schema": {
"type": "string"
}
} }
], ],
"responses": { "responses": {
@@ -8142,6 +8200,14 @@
"schema": { "schema": {
"type": "string" "type": "string"
} }
},
{
"name": "Authorization",
"required": true,
"in": "header",
"schema": {
"type": "string"
}
} }
], ],
"responses": { "responses": {
@@ -8189,6 +8255,14 @@
"schema": { "schema": {
"type": "number" "type": "number"
} }
},
{
"name": "Authorization",
"required": true,
"in": "header",
"schema": {
"type": "string"
}
} }
], ],
"responses": { "responses": {
@@ -8236,6 +8310,14 @@
"schema": { "schema": {
"type": "boolean" "type": "boolean"
} }
},
{
"name": "Authorization",
"required": true,
"in": "header",
"schema": {
"type": "string"
}
} }
], ],
"responses": { "responses": {
@@ -8275,6 +8357,14 @@
"schema": { "schema": {
"type": "string" "type": "string"
} }
},
{
"name": "Authorization",
"required": true,
"in": "header",
"schema": {
"type": "string"
}
} }
], ],
"responses": { "responses": {
@@ -8314,6 +8404,14 @@
"schema": { "schema": {
"type": "string" "type": "string"
} }
},
{
"name": "Authorization",
"required": true,
"in": "header",
"schema": {
"type": "string"
}
} }
], ],
"responses": { "responses": {
@@ -8369,6 +8467,14 @@
"schema": { "schema": {
"type": "string" "type": "string"
} }
},
{
"name": "Authorization",
"required": true,
"in": "header",
"schema": {
"type": "string"
}
} }
], ],
"responses": { "responses": {
@@ -8408,6 +8514,14 @@
"schema": { "schema": {
"type": "string" "type": "string"
} }
},
{
"name": "Authorization",
"required": true,
"in": "header",
"schema": {
"type": "string"
}
} }
], ],
"responses": { "responses": {
@@ -8439,7 +8553,16 @@
"post": { "post": {
"operationId": "StorageExplorerController_batchUpload", "operationId": "StorageExplorerController_batchUpload",
"summary": "Upload multiple files to storage", "summary": "Upload multiple files to storage",
"parameters": [], "parameters": [
{
"name": "Authorization",
"required": true,
"in": "header",
"schema": {
"type": "string"
}
}
],
"responses": { "responses": {
"201": { "201": {
"description": "", "description": "",
@@ -8469,7 +8592,16 @@
"post": { "post": {
"operationId": "StorageExplorerController_createFolder", "operationId": "StorageExplorerController_createFolder",
"summary": "Create a new folder in storage", "summary": "Create a new folder in storage",
"parameters": [], "parameters": [
{
"name": "Authorization",
"required": true,
"in": "header",
"schema": {
"type": "string"
}
}
],
"responses": { "responses": {
"201": { "201": {
"description": "", "description": "",
@@ -8507,6 +8639,14 @@
"schema": { "schema": {
"type": "string" "type": "string"
} }
},
{
"name": "Authorization",
"required": true,
"in": "header",
"schema": {
"type": "string"
}
} }
], ],
"responses": { "responses": {
@@ -8546,6 +8686,14 @@
"schema": { "schema": {
"type": "string" "type": "string"
} }
},
{
"name": "Authorization",
"required": true,
"in": "header",
"schema": {
"type": "string"
}
} }
], ],
"responses": { "responses": {
+1 -1
View File
@@ -502,7 +502,7 @@ export class AuthController {
const accessToken = req.cookies['ddf-auth']; const accessToken = req.cookies['ddf-auth'];
const refreshToken = req.cookies['ddf-refresh-auth']; const refreshToken = req.cookies['ddf-refresh-auth'];
const userId = req.cookies['ddf-user-id']; const userId = req.cookies['ddf-user-id'];
const resourceHost = req.headers["x-original-url"] as string || "" ; const resourceHost = req.headers["host"]
const hasUserSession = Boolean(accessToken) && Boolean(userId); const hasUserSession = Boolean(accessToken) && Boolean(userId);
this.logger.info('Has User Session: ' + hasUserSession); this.logger.info('Has User Session: ' + hasUserSession);
@@ -6,7 +6,7 @@ export const STORAGE_EXPLORER_CONFIG = {
} }
// Replace {customer_id} placeholder with actual customer ID // Replace {customer_id} placeholder with actual customer ID
// For local: http://172.17.0.1:8000/api (no placeholder) // For local: http://172.17.0.1:8000/api (no placeholder)
// For prod: https://storage-explorer-{customer_id}.dadosfera.ai/api // For prod: https://storage-explorer-{customer_id}.stg.dadosfera.ai/api
return urlTemplate.replace('{customer}', customerName); return urlTemplate.replace('{customer}', customerName);
}, },
timeout: parseInt(process.env.STORAGE_EXPLORER_TIMEOUT || '30000', 10), timeout: parseInt(process.env.STORAGE_EXPLORER_TIMEOUT || '30000', 10),
@@ -47,13 +47,13 @@ export class StorageExplorerController {
async validateTableName( async validateTableName(
@Body() body: any, @Body() body: any,
@User() user: RequestUser, @User() user: RequestUser,
@Headers('Authorization') token: string
) { ) {
return this.storageExplorerService.proxy( return this.storageExplorerService.proxy(
'POST', 'POST',
'/tables/validate-name', '/tables/validate-name',
user, user,
token,
body, body,
); );
} }
@@ -64,13 +64,13 @@ export class StorageExplorerController {
async createTable( async createTable(
@Body() body: any, @Body() body: any,
@User() user: RequestUser, @User() user: RequestUser,
@Headers('Authorization') token: string
) { ) {
return this.storageExplorerService.proxy( return this.storageExplorerService.proxy(
'POST', 'POST',
'/tables/', '/tables/',
user, user,
token,
body, body,
); );
} }
@@ -81,13 +81,13 @@ export class StorageExplorerController {
async listTables( async listTables(
@Query('page') page: number, @Query('page') page: number,
@User() user: RequestUser, @User() user: RequestUser,
@Headers('Authorization') token: string
) { ) {
return this.storageExplorerService.proxy( return this.storageExplorerService.proxy(
'GET', 'GET',
'/tables/', '/tables/',
user, user,
token,
undefined, undefined,
{ page }, { page },
); );
@@ -99,12 +99,13 @@ export class StorageExplorerController {
async getTable( async getTable(
@Param('tableId') tableId: string, @Param('tableId') tableId: string,
@User() user: RequestUser, @User() user: RequestUser,
@Headers('Authorization') token: string
) { ) {
return this.storageExplorerService.proxy( return this.storageExplorerService.proxy(
'GET', 'GET',
`/tables/${tableId}`, `/tables/${tableId}`,
user, user,
token
); );
} }
@@ -115,13 +116,13 @@ export class StorageExplorerController {
@Param('tableId') tableId: string, @Param('tableId') tableId: string,
@Param('datasetId') datasetId: string, @Param('datasetId') datasetId: string,
@User() user: RequestUser, @User() user: RequestUser,
@Headers('Authorization') token: string
) { ) {
return this.storageExplorerService.proxy( return this.storageExplorerService.proxy(
'POST', 'POST',
`/tables/${tableId}/datasets/${datasetId}`, `/tables/${tableId}/datasets/${datasetId}`,
user, user,
token
); );
} }
@@ -131,13 +132,13 @@ export class StorageExplorerController {
async getTableDatasets( async getTableDatasets(
@Param('tableId') tableId: string, @Param('tableId') tableId: string,
@User() user: RequestUser, @User() user: RequestUser,
@Headers('Authorization') token: string
) { ) {
return this.storageExplorerService.proxy( return this.storageExplorerService.proxy(
'GET', 'GET',
`/tables/${tableId}/datasets`, `/tables/${tableId}/datasets`,
user, user,
token
); );
} }
@@ -147,13 +148,13 @@ export class StorageExplorerController {
async getTableSchema( async getTableSchema(
@Param('tableId') tableId: string, @Param('tableId') tableId: string,
@User() user: RequestUser, @User() user: RequestUser,
@Headers('Authorization') token: string
) { ) {
return this.storageExplorerService.proxy( return this.storageExplorerService.proxy(
'GET', 'GET',
`/tables/${tableId}/schema`, `/tables/${tableId}/schema`,
user, user,
token
); );
} }
@@ -164,12 +165,13 @@ export class StorageExplorerController {
@Param('tableId') tableId: string, @Param('tableId') tableId: string,
@Param('datasetId') datasetId: string, @Param('datasetId') datasetId: string,
@User() user: RequestUser, @User() user: RequestUser,
@Headers('Authorization') token: string
) { ) {
return this.storageExplorerService.proxy( return this.storageExplorerService.proxy(
'POST', 'POST',
`/tables/${tableId}/validate-compatibility/${datasetId}`, `/tables/${tableId}/validate-compatibility/${datasetId}`,
user, user,
token
); );
} }
@@ -184,13 +186,13 @@ export class StorageExplorerController {
@Param('datasetId') datasetId: string, @Param('datasetId') datasetId: string,
@Query('limit') limit: number, @Query('limit') limit: number,
@User() user: RequestUser, @User() user: RequestUser,
@Headers('Authorization') token: string
) { ) {
return this.storageExplorerService.proxy( return this.storageExplorerService.proxy(
'GET', 'GET',
`/datasets/${datasetId}/preview`, `/datasets/${datasetId}/preview`,
user, user,
token,
undefined, undefined,
{ limit }, { limit },
); );
@@ -203,13 +205,13 @@ export class StorageExplorerController {
@Param('datasetId') datasetId: string, @Param('datasetId') datasetId: string,
@Query('force_refresh') forceRefresh: boolean, @Query('force_refresh') forceRefresh: boolean,
@User() user: RequestUser, @User() user: RequestUser,
@Headers('Authorization') token: string
) { ) {
return this.storageExplorerService.proxy( return this.storageExplorerService.proxy(
'GET', 'GET',
`/datasets/${datasetId}/schema`, `/datasets/${datasetId}/schema`,
user, user,
token,
undefined, undefined,
{ force_refresh: forceRefresh }, { force_refresh: forceRefresh },
); );
@@ -221,13 +223,13 @@ export class StorageExplorerController {
async listDatasetsByUpload( async listDatasetsByUpload(
@Param('uploadId') uploadId: string, @Param('uploadId') uploadId: string,
@User() user: RequestUser, @User() user: RequestUser,
@Headers('Authorization') token: string
) { ) {
return this.storageExplorerService.proxy( return this.storageExplorerService.proxy(
'GET', 'GET',
`/datasets/upload/${uploadId}`, `/datasets/upload/${uploadId}`,
user, user,
token
); );
} }
@@ -238,13 +240,13 @@ export class StorageExplorerController {
@Param('datasetId') datasetId: string, @Param('datasetId') datasetId: string,
@Body() body: any, @Body() body: any,
@User() user: RequestUser, @User() user: RequestUser,
@Headers('Authorization') token: string
) { ) {
return this.storageExplorerService.proxy( return this.storageExplorerService.proxy(
'PUT', 'PUT',
`/datasets/${datasetId}/refresh-schema`, `/datasets/${datasetId}/refresh-schema`,
user, user,
token,
body, body,
); );
} }
@@ -261,13 +263,13 @@ export class StorageExplorerController {
@Query('limit') limit: number, @Query('limit') limit: number,
@Query('folder_path') folderPath: string, @Query('folder_path') folderPath: string,
@User() user: RequestUser, @User() user: RequestUser,
@Headers('Authorization') token: string
) { ) {
return this.storageExplorerService.proxy( return this.storageExplorerService.proxy(
'GET', 'GET',
'/storage/uploads/history', '/storage/uploads/history',
user, user,
token,
undefined, undefined,
{ page, limit, folder_path: folderPath }, { page, limit, folder_path: folderPath },
); );
@@ -279,13 +281,13 @@ export class StorageExplorerController {
async browseStorage( async browseStorage(
@Query('path') path: string, @Query('path') path: string,
@User() user: RequestUser, @User() user: RequestUser,
@Headers('Authorization') token: string
) { ) {
return this.storageExplorerService.proxy( return this.storageExplorerService.proxy(
'GET', 'GET',
'/storage/browse', '/storage/browse',
user, user,
token,
undefined, undefined,
{ path }, { path },
); );
@@ -300,7 +302,7 @@ export class StorageExplorerController {
@UploadedFiles() files: Array<Express.Multer.File>, @UploadedFiles() files: Array<Express.Multer.File>,
@Body('folder_path') folderPath: string, @Body('folder_path') folderPath: string,
@User() user: RequestUser, @User() user: RequestUser,
@Headers('Authorization') token: string
) { ) {
// Create FormData to forward files to storage-explorer API // Create FormData to forward files to storage-explorer API
const formData = new FormData(); const formData = new FormData();
@@ -324,7 +326,7 @@ export class StorageExplorerController {
'POST', 'POST',
'/storage/upload/batch', '/storage/upload/batch',
user, user,
token,
formData, formData,
); );
} }
@@ -335,13 +337,13 @@ export class StorageExplorerController {
async createFolder( async createFolder(
@Body() body: any, @Body() body: any,
@User() user: RequestUser, @User() user: RequestUser,
@Headers('Authorization') token: string
) { ) {
return this.storageExplorerService.proxy( return this.storageExplorerService.proxy(
'POST', 'POST',
'/storage/folder/create', '/storage/folder/create',
user, user,
token,
body, body,
); );
} }
@@ -352,13 +354,13 @@ export class StorageExplorerController {
async downloadFile( async downloadFile(
@Query('file_path') filePath: string, @Query('file_path') filePath: string,
@User() user: RequestUser, @User() user: RequestUser,
@Headers('Authorization') token: string
) { ) {
return this.storageExplorerService.proxy( return this.storageExplorerService.proxy(
'GET', 'GET',
'/storage/download', '/storage/download',
user, user,
token,
undefined, undefined,
{ file_path: filePath }, { file_path: filePath },
); );
@@ -370,12 +372,13 @@ export class StorageExplorerController {
async getFileMetadata( async getFileMetadata(
@Query('file_path') filePath: string, @Query('file_path') filePath: string,
@User() user: RequestUser, @User() user: RequestUser,
@Headers('Authorization') token: string
) { ) {
return this.storageExplorerService.proxy( return this.storageExplorerService.proxy(
'GET', 'GET',
'/storage/metadata', '/storage/metadata',
user, user,
token,
undefined, undefined,
{ file_path: filePath }, { file_path: filePath },
); );
@@ -19,6 +19,7 @@ export class StorageExplorerService {
method: string, method: string,
path: string, path: string,
user: RequestUser, user: RequestUser,
token: string,
body?: any, body?: any,
query?: Record<string, any> query?: Record<string, any>
): Promise<any> { ): Promise<any> {
@@ -41,6 +42,7 @@ export class StorageExplorerService {
} }
const headers: Record<string, string> = { const headers: Record<string, string> = {
'Authorization': token,
'content-type': 'application/json', 'content-type': 'application/json',
}; };
@@ -113,7 +115,7 @@ export class StorageExplorerService {
} }
// Get customer-specific storage-explorer URL // Get customer-specific storage-explorer URL
const baseUrl = STORAGE_EXPLORER_CONFIG.getUrl(user.customer_name); const baseUrl = STORAGE_EXPLORER_CONFIG.getUrl(user.customer_id);
const url = new URL(`${baseUrl}${path}`); const url = new URL(`${baseUrl}${path}`);
// Add query params // Add query params