mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-23 00:44:24 +01:00
Rewrite the CanUseHotWallet, check if the derivationscheme is actually a hotwallet, before retrieving the seed
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using BTCPayServer.Abstractions.Constants;
|
||||
using BTCPayServer.Client;
|
||||
using BTCPayServer.Security.Bitpay;
|
||||
using BTCPayServer.Security.GreenField;
|
||||
using BTCPayServer.Services;
|
||||
using CsvHelper.Configuration.Attributes;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
|
||||
namespace BTCPayServer
|
||||
@@ -15,8 +17,19 @@ namespace BTCPayServer
|
||||
PoliciesSettings policiesSettings,
|
||||
ClaimsPrincipal user)
|
||||
{
|
||||
return (await authorizationService.AuthorizeAsync(user, Policies.CanModifyServerSettings))
|
||||
.Succeeded ? (true, true) : (policiesSettings?.AllowHotWalletForAll is true, policiesSettings?.AllowHotWalletRPCImportForAll is true);
|
||||
if (!user.Identity.IsAuthenticated)
|
||||
return (false, false);
|
||||
var claimUser = user.Identity as ClaimsIdentity;
|
||||
if (claimUser is null)
|
||||
return (false, false);
|
||||
|
||||
bool isAdmin = false;
|
||||
if (claimUser.AuthenticationType == AuthenticationSchemes.Cookie)
|
||||
isAdmin = user.IsInRole(Roles.ServerAdmin);
|
||||
else if (claimUser.AuthenticationType == GreenFieldConstants.AuthenticationType)
|
||||
isAdmin = (await authorizationService.AuthorizeAsync(user, Policies.CanModifyServerSettings)).Succeeded;
|
||||
return isAdmin ? (true, true) :
|
||||
(policiesSettings?.AllowHotWalletForAll is true, policiesSettings?.AllowHotWalletRPCImportForAll is true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user