mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2026-01-03 06:04:24 +01:00
Merge pull request #6471 from dennisreimann/fix-throttle
POS: Fix throttling for unauthenticated users
This commit is contained in:
@@ -2903,6 +2903,16 @@ namespace BTCPayServer.Tests
|
||||
// Unauthenticated user can't access recent transactions
|
||||
s.GoToUrl(keypadUrl);
|
||||
s.Driver.ElementDoesNotExist(By.Id("RecentTransactionsToggle"));
|
||||
|
||||
// But they can generate invoices
|
||||
s.Driver.FindElement(By.CssSelector(".keypad [data-key='1']")).Click();
|
||||
s.Driver.FindElement(By.CssSelector(".keypad [data-key='2']")).Click();
|
||||
s.Driver.FindElement(By.CssSelector(".keypad [data-key='3']")).Click();
|
||||
s.Driver.FindElement(By.Id("pay-button")).Click();
|
||||
s.Driver.WaitUntilAvailable(By.Id("Checkout"));
|
||||
s.Driver.FindElement(By.Id("DetailsToggle")).Click();
|
||||
s.Driver.WaitForElement(By.Id("PaymentDetails-TotalFiat"));
|
||||
Assert.Contains("1,23 €", s.Driver.FindElement(By.Id("PaymentDetails-TotalFiat")).Text);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
@@ -430,9 +430,9 @@ namespace BTCPayServer.Plugins.PointOfSale.Controllers
|
||||
}
|
||||
|
||||
private async Task<bool> Throttle(string appId) =>
|
||||
HttpContext.Connection is { RemoteIpAddress: { } addr } &&
|
||||
await _rateLimitService.Throttle(ZoneLimits.PublicInvoices, addr.ToString(), HttpContext.RequestAborted) &&
|
||||
!(await _authorizationService.AuthorizeAsync(HttpContext.User, appId, Policies.CanViewInvoices)).Succeeded;
|
||||
!(await _authorizationService.AuthorizeAsync(HttpContext.User, appId, Policies.CanViewInvoices)).Succeeded &&
|
||||
HttpContext.Connection is { RemoteIpAddress: { } addr } &&
|
||||
!await _rateLimitService.Throttle(ZoneLimits.PublicInvoices, addr.ToString(), HttpContext.RequestAborted);
|
||||
|
||||
private JObject TryParseJObject(string posData)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user