mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-17 22:14:26 +01:00
Bypass MVC for replying to CORS requests if Bitpay API
This commit is contained in:
@@ -14,8 +14,7 @@ using System.Threading.Tasks;
|
|||||||
namespace BTCPayServer.Controllers
|
namespace BTCPayServer.Controllers
|
||||||
{
|
{
|
||||||
[Authorize(AuthenticationSchemes = Security.Policies.BitpayAuthentication)]
|
[Authorize(AuthenticationSchemes = Security.Policies.BitpayAuthentication)]
|
||||||
[BitpayAPIConstraint(true)]
|
[BitpayAPIConstraint()]
|
||||||
[EnableCors(CorsPolicies.All)]
|
|
||||||
public class AccessTokenController : Controller
|
public class AccessTokenController : Controller
|
||||||
{
|
{
|
||||||
TokenRepository _TokenRepository;
|
TokenRepository _TokenRepository;
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ using NBitpayClient;
|
|||||||
namespace BTCPayServer.Controllers
|
namespace BTCPayServer.Controllers
|
||||||
{
|
{
|
||||||
[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
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -38,6 +38,11 @@ namespace BTCPayServer.Hosting
|
|||||||
{
|
{
|
||||||
var bitpayAuth = GetBitpayAuth(httpContext, out bool isBitpayAuth);
|
var bitpayAuth = GetBitpayAuth(httpContext, out bool isBitpayAuth);
|
||||||
var isBitpayAPI = IsBitpayAPI(httpContext, isBitpayAuth);
|
var isBitpayAPI = IsBitpayAPI(httpContext, isBitpayAuth);
|
||||||
|
if (isBitpayAPI && httpContext.Request.Method == "OPTIONS")
|
||||||
|
{
|
||||||
|
httpContext.Response.StatusCode = 200;
|
||||||
|
return; // We bypass MVC completely
|
||||||
|
}
|
||||||
httpContext.SetIsBitpayAPI(isBitpayAPI);
|
httpContext.SetIsBitpayAPI(isBitpayAPI);
|
||||||
if (isBitpayAPI)
|
if (isBitpayAPI)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user