Update managing api security

This commit is contained in:
2025-11-01 18:01:08 +07:00
parent 56c22ce806
commit b8c6f05805
8 changed files with 296 additions and 62 deletions

View File

@@ -1,4 +1,6 @@
using Managing.Api.Models.Requests;
using System.Net.Http.Headers;
using System.Text;
using Managing.Api.Models.Requests;
using Managing.Application.Abstractions;
using Managing.Application.Abstractions.Services;
using Managing.Application.Shared;
@@ -289,6 +291,16 @@ public class TradingController : BaseController
var httpClient = _httpClientFactory.CreateClient();
// Add basic authentication if credentials are provided
var username = _configuration["N8n:Username"];
var password = _configuration["N8n:Password"];
if (!string.IsNullOrEmpty(username) && !string.IsNullOrEmpty(password))
{
var credentials = Convert.ToBase64String(Encoding.UTF8.GetBytes($"{username}:{password}"));
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", credentials);
}
_logger.LogInformation(
"Submitting indicator request: {IndicatorName} - {Strategy} by {Requester}",
request.IndicatorName,