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 System.Net.Http.Headers;
using System.Net.Http.Json;
using System.Text;
using Managing.Application.Abstractions.Services;
using Managing.Common;
using Managing.Domain.Users;
@@ -20,6 +22,16 @@ public class WebhookService : IWebhookService
_configuration = configuration;
_logger = logger;
_n8nWebhookUrl = _configuration["N8n:WebhookUrl"] ?? string.Empty;
// Configure 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);
}
}
public async Task SendTradeNotification(User user, string message, bool isBadBehavior = false)