Disable orleans reminder for deploy and add whitelisted addresses

This commit is contained in:
2025-08-15 16:48:23 +07:00
parent 54bf914e95
commit 0966eace58
12 changed files with 188 additions and 29 deletions

View File

@@ -5,6 +5,7 @@ using Managing.Application.Abstractions.Services;
using Managing.Common;
using Managing.Domain.Accounts;
using Managing.Domain.Users;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
namespace Managing.Application.Users;
@@ -17,20 +18,7 @@ public class UserService : IUserService
private readonly ILogger<UserService> _logger;
private readonly ICacheService _cacheService;
private readonly IGrainFactory _grainFactory;
private string[] authorizedAddresses =
[
"0x6781920674dA695aa5120d95D80c4B1788046806", // Macbook
"0xA2B43AFF0992a47838DF2e6099A8439981f0B717", // Phone
"0xAD4bcf258852e9d47E580798d312E1a52D59E721", // Razil
"0xAd6D6c80910096b40e45690506a9f1052e072dCB", // Teru
"0x309b9235edbe1C6f840816771c6C21aDa6c275EE", // Cowchain
"0x23AA99254cfaA2c374bE2bA5B55C68018cCdFCb3", // Local optiflex
"0x932167388dD9aad41149b3cA23eBD489E2E2DD78", // Embedded wallet
"0x66CB57Fe3f53cE57376421106dFDa2D39186cBd0", // Embedded wallet optiflex
"0x7baBf95621f22bEf2DB67E500D022Ca110722FaD", // DevCowchain
"0xc8bC497534d0A43bAb2BBA9BA94d46D9Ddfaea6B" // DevCowchain2
];
private readonly string[] _authorizedAddresses;
public UserService(
IEvmManager evmManager,
@@ -38,7 +26,8 @@ public class UserService : IUserService
IAccountService accountService,
ILogger<UserService> logger,
ICacheService cacheService,
IGrainFactory grainFactory)
IGrainFactory grainFactory,
IConfiguration configuration)
{
_evmManager = evmManager;
_userRepository = userRepository;
@@ -46,6 +35,11 @@ public class UserService : IUserService
_logger = logger;
_cacheService = cacheService;
_grainFactory = grainFactory;
var authorizedAddressesString = configuration["AUTHORIZED_ADDRESSES"] ?? string.Empty;
_authorizedAddresses = string.IsNullOrEmpty(authorizedAddressesString)
? Array.Empty<string>()
: authorizedAddressesString.Split(';', StringSplitOptions.RemoveEmptyEntries);
}
public async Task<User> Authenticate(string name, string address, string message, string signature)
@@ -60,11 +54,11 @@ public class UserService : IUserService
$"Message not good : {message} - Address : {address} - User : {name} - Signature : {signature}");
}
// if (!authorizedAddresses.Contains(recoveredAddress))
// {
// _logger.LogWarning($"Address {recoveredAddress} not authorized");
// throw new Exception("Address not authorized");
// }
if (!_authorizedAddresses.Contains(recoveredAddress.ToLower()))
{
_logger.LogWarning($"Address {recoveredAddress} not authorized");
throw new Exception("Address not authorized");
}
if (recoveredAddress == null || !recoveredAddress.Equals(address))
{