mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-18 06:24:24 +01:00
28 lines
745 B
C#
28 lines
745 B
C#
using System;
|
|
using Microsoft.AspNetCore.Mvc.Filters;
|
|
|
|
namespace BTCPayServer.Filters
|
|
{
|
|
public interface IReferrerPolicy : IFilterMetadata { }
|
|
public class ReferrerPolicyAttribute : Attribute, IActionFilter
|
|
{
|
|
public ReferrerPolicyAttribute(string value)
|
|
{
|
|
Value = value;
|
|
}
|
|
public string Value { get; set; }
|
|
public void OnActionExecuted(ActionExecutedContext context)
|
|
{
|
|
|
|
}
|
|
|
|
public void OnActionExecuting(ActionExecutingContext context)
|
|
{
|
|
if (context.IsEffectivePolicy<ReferrerPolicyAttribute>(this))
|
|
{
|
|
context.HttpContext.Response.SetHeaderOnStarting("Referrer-Policy", Value);
|
|
}
|
|
}
|
|
}
|
|
}
|