< Summary

Information
Class: ProjectTemplate.Web.Options.ApplicationSecurityHeadersOptions
Assembly: ProjectTemplate.Web
File(s): /home/runner/work/NetCoreApplicationTemplate/NetCoreApplicationTemplate/src/ProjectTemplate.Web/Options/ApplicationSecurityHeadersOptions.cs
Line coverage
100%
Covered lines: 21
Uncovered lines: 0
Coverable lines: 21
Total lines: 61
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_SectionName()100%11100%
get_Enabled()100%11100%
get_EnableContentSecurityPolicy()100%11100%
get_EnablePermissionsPolicy()100%11100%
get_EnableCrossOriginHeaders()100%11100%
get_ContentSecurityPolicy()100%11100%
.ctor()100%11100%
get_PermissionsPolicy()100%11100%
get_ExcludedPathPrefixes()100%11100%

File(s)

/home/runner/work/NetCoreApplicationTemplate/NetCoreApplicationTemplate/src/ProjectTemplate.Web/Options/ApplicationSecurityHeadersOptions.cs

#LineLine coverage
 1namespace ProjectTemplate.Web.Options;
 2
 3/// <summary>
 4/// Options to control which security-related HTTP headers are applied by the application.
 5/// </summary>
 6public sealed class ApplicationSecurityHeadersOptions
 7{
 8    /// <summary>
 9    /// Gets the configuration section name used to bind security header settings.
 10    /// </summary>
 15411    public static string SectionName { get; internal set; } = "ProjectTemplate:SecurityHeaders";
 12
 13    /// <summary>
 14    /// Gets or sets a value indicating whether security headers are enabled.
 15    /// </summary>
 63616    public bool Enabled { get; set; } = true;
 17
 18    /// <summary>
 19    /// Gets or sets a value indicating whether the Content-Security-Policy header is applied.
 20    /// </summary>
 87421    public bool EnableContentSecurityPolicy { get; set; } = true;
 22
 23    /// <summary>
 24    /// Gets or sets a value indicating whether the Permissions-Policy header is applied.
 25    /// </summary>
 87626    public bool EnablePermissionsPolicy { get; set; } = true;
 27
 28    /// <summary>
 29    /// Gets or sets a value indicating whether cross-origin related headers are applied.
 30    /// </summary>
 61831    public bool EnableCrossOriginHeaders { get; set; } = true;
 32
 33    /// <summary>
 34    /// Gets or sets the Content-Security-Policy header value applied to responses.
 35    /// </summary>
 70636    public string ContentSecurityPolicy { get; set; } =
 25837        "default-src 'self'; " +
 25838        "base-uri 'self'; " +
 25839        "object-src 'none'; " +
 25840        "frame-ancestors 'none'; " +
 25841        "form-action 'self'; " +
 25842        "img-src 'self' data:; " +
 25843        "script-src 'self'; " +
 25844        "style-src 'self' 'unsafe-inline';";
 45
 46    /// <summary>
 47    /// Gets or sets the Permissions-Policy header value applied to responses.
 48    /// Set EnablePermissionsPolicy to false to omit the header.
 49    /// </summary>
 70850    public string PermissionsPolicy { get; set; } =
 25851        "camera=(), microphone=(), geolocation=(), payment=(), usb=(), fullscreen=(self)";
 52
 53    /// <summary>
 54    /// Gets or sets path prefixes that are excluded from applying the security headers.
 55    /// </summary>
 89256    public List<string> ExcludedPathPrefixes { get; set; } =
 25857    [
 25858            "/health",
 25859            "/metrics"
 25860    ];
 61}