mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-17 22:14:26 +01:00
Make sure CORS is enabled on Bitpay's API
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
using BTCPayServer.Filters;
|
using BTCPayServer.Filters;
|
||||||
using BTCPayServer.Models;
|
using BTCPayServer.Models;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Cors;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using NBitcoin.DataEncoders;
|
using NBitcoin.DataEncoders;
|
||||||
using NBitpayClient;
|
using NBitpayClient;
|
||||||
@@ -14,6 +15,7 @@ namespace BTCPayServer.Controllers
|
|||||||
{
|
{
|
||||||
[Authorize(AuthenticationSchemes = Security.Policies.BitpayAuthentication)]
|
[Authorize(AuthenticationSchemes = Security.Policies.BitpayAuthentication)]
|
||||||
[BitpayAPIConstraint(true)]
|
[BitpayAPIConstraint(true)]
|
||||||
|
[EnableCors(CorsPolicies.All)]
|
||||||
public class AccessTokenController : Controller
|
public class AccessTokenController : Controller
|
||||||
{
|
{
|
||||||
TokenRepository _TokenRepository;
|
TokenRepository _TokenRepository;
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ using NBitpayClient;
|
|||||||
|
|
||||||
namespace BTCPayServer.Controllers
|
namespace BTCPayServer.Controllers
|
||||||
{
|
{
|
||||||
[EnableCors("BitpayAPI")]
|
|
||||||
[BitpayAPIConstraint]
|
[BitpayAPIConstraint]
|
||||||
|
[EnableCors(CorsPolicies.All)]
|
||||||
[Authorize(Policies.CanCreateInvoice.Key, AuthenticationSchemes = Policies.BitpayAuthentication)]
|
[Authorize(Policies.CanCreateInvoice.Key, AuthenticationSchemes = Policies.BitpayAuthentication)]
|
||||||
public class InvoiceControllerAPI : Controller
|
public class InvoiceControllerAPI : Controller
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -12,11 +12,13 @@ using BTCPayServer.Rating;
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using BTCPayServer.Authentication;
|
using BTCPayServer.Authentication;
|
||||||
|
using Microsoft.AspNetCore.Cors;
|
||||||
|
|
||||||
namespace BTCPayServer.Controllers
|
namespace BTCPayServer.Controllers
|
||||||
{
|
{
|
||||||
[Authorize(AuthenticationSchemes = Security.Policies.BitpayAuthentication)]
|
[Authorize(AuthenticationSchemes = Security.Policies.BitpayAuthentication)]
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
|
[EnableCors(CorsPolicies.All)]
|
||||||
public class RateController : Controller
|
public class RateController : Controller
|
||||||
{
|
{
|
||||||
RateFetcher _RateProviderFactory;
|
RateFetcher _RateProviderFactory;
|
||||||
|
|||||||
@@ -92,14 +92,6 @@ namespace BTCPayServer.Hosting
|
|||||||
options.Lockout.MaxFailedAccessAttempts = 5;
|
options.Lockout.MaxFailedAccessAttempts = 5;
|
||||||
options.Lockout.AllowedForNewUsers = true;
|
options.Lockout.AllowedForNewUsers = true;
|
||||||
});
|
});
|
||||||
services.AddCors(o =>
|
|
||||||
{
|
|
||||||
o.AddPolicy("BitpayAPI", b =>
|
|
||||||
{
|
|
||||||
b.AllowAnyMethod().AllowAnyHeader().AllowAnyOrigin();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// If the HTTPS certificate path is not set this logic will NOT be used and the default Kestrel binding logic will be.
|
// If the HTTPS certificate path is not set this logic will NOT be used and the default Kestrel binding logic will be.
|
||||||
string httpsCertificateFilePath = Configuration.GetOrDefault<string>("HttpsCertificateFilePath", null);
|
string httpsCertificateFilePath = Configuration.GetOrDefault<string>("HttpsCertificateFilePath", null);
|
||||||
bool useDefaultCertificate = Configuration.GetOrDefault<bool>("HttpsUseDefaultCertificate", false);
|
bool useDefaultCertificate = Configuration.GetOrDefault<bool>("HttpsUseDefaultCertificate", false);
|
||||||
|
|||||||
Reference in New Issue
Block a user