Update managing api security
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user