mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-18 14:34:23 +01:00
X-Frame-Options
This commit is contained in:
@@ -95,6 +95,7 @@ namespace BTCPayServer.Controllers
|
|||||||
[Route("i/{invoiceId}")]
|
[Route("i/{invoiceId}")]
|
||||||
[Route("invoice")]
|
[Route("invoice")]
|
||||||
[AcceptMediaTypeConstraint("application/bitcoin-paymentrequest", false)]
|
[AcceptMediaTypeConstraint("application/bitcoin-paymentrequest", false)]
|
||||||
|
[XFrameOptionsAttribute(null)]
|
||||||
public async Task<IActionResult> Checkout(string invoiceId, string id = null)
|
public async Task<IActionResult> Checkout(string invoiceId, string id = null)
|
||||||
{
|
{
|
||||||
//Keep compatibility with Bitpay
|
//Keep compatibility with Bitpay
|
||||||
|
|||||||
33
BTCPayServer/Filters/XFrameOptionsAttribute.cs
Normal file
33
BTCPayServer/Filters/XFrameOptionsAttribute.cs
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
using Microsoft.AspNetCore.Mvc.Filters;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace BTCPayServer.Filters
|
||||||
|
{
|
||||||
|
public class XFrameOptionsAttribute : Attribute, IActionFilter
|
||||||
|
{
|
||||||
|
public XFrameOptionsAttribute(string value)
|
||||||
|
{
|
||||||
|
Value = value;
|
||||||
|
}
|
||||||
|
public string Value
|
||||||
|
{
|
||||||
|
get; set;
|
||||||
|
}
|
||||||
|
public void OnActionExecuted(ActionExecutedContext context)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnActionExecuting(ActionExecutingContext context)
|
||||||
|
{
|
||||||
|
var existing = context.HttpContext.Response.Headers["x-frame-options"].FirstOrDefault();
|
||||||
|
if(existing != null && Value == null)
|
||||||
|
context.HttpContext.Response.Headers.Remove("x-frame-options");
|
||||||
|
else
|
||||||
|
context.HttpContext.Response.Headers["x-frame-options"] = Value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -74,7 +74,10 @@ namespace BTCPayServer.Hosting
|
|||||||
// Big hack, tests fails because Hangfire fail at initializing at the second test run
|
// Big hack, tests fails because Hangfire fail at initializing at the second test run
|
||||||
AddHangfireFix(services);
|
AddHangfireFix(services);
|
||||||
services.AddBTCPayServer();
|
services.AddBTCPayServer();
|
||||||
services.AddMvc();
|
services.AddMvc(o =>
|
||||||
|
{
|
||||||
|
o.Filters.Add(new XFrameOptionsAttribute("DENY"));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Big hack, tests fails if only call AddHangfire because Hangfire fail at initializing at the second test run
|
// Big hack, tests fails if only call AddHangfire because Hangfire fail at initializing at the second test run
|
||||||
|
|||||||
Reference in New Issue
Block a user