-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDisableCspPageFilter.cs
More file actions
36 lines (33 loc) · 1.08 KB
/
DisableCspPageFilter.cs
File metadata and controls
36 lines (33 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using Galebra.Security.Headers.Csp.Infrastructure;
using Microsoft.AspNetCore.Mvc.Filters;
namespace Galebra.Security.Headers.Csp
{
/// <summary>
/// <inheritdoc cref="IDisableCspFilterAttribute"/>.<br/>
/// <see cref="EnforceMode"/> defaults to true
/// </summary>
public sealed class DisableCspPageFilter : IPageFilter, IDisableCspFilterAttribute
{
/// <summary>
/// <inheritdoc cref="DisableCspPageFilter"/>
/// </summary>
public DisableCspPageFilter()
{
}
/// <summary>
/// <inheritdoc/>.<br/>
/// Defaults to true
/// </summary>
public bool EnforceMode { get; init; } = true;
public void OnPageHandlerSelected(PageHandlerSelectedContext context)
{
context.HttpContext.Items[CspConstants.DisableCspResultFilterAttributeKey] = EnforceMode;
}
public void OnPageHandlerExecuting(PageHandlerExecutingContext context)
{
}
public void OnPageHandlerExecuted(PageHandlerExecutedContext context)
{
}
}
}