< Summary

Information
Class: ProjectTemplate.Web.Options.ApplicationForwardedHeadersOptions
Assembly: ProjectTemplate.Web
File(s): /home/runner/work/NetCoreApplicationTemplate/NetCoreApplicationTemplate/src/ProjectTemplate.Web/Options/ApplicationForwardedHeadersOptions.cs
Line coverage
100%
Covered lines: 13
Uncovered lines: 0
Coverable lines: 13
Total lines: 67
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_Enabled()100%11100%
get_RequireExplicitProxyTrust()100%11100%
get_Headers()100%11100%
.ctor()100%11100%
get_ForwardLimit()100%11100%
get_RequireHeaderSymmetry()100%11100%
get_ClearKnownNetworksAndProxies()100%11100%
get_KnownProxies()100%11100%
get_KnownNetworks()100%11100%
get_AllowedHosts()100%11100%

File(s)

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

#LineLine coverage
 1namespace ProjectTemplate.Web.Options;
 2
 3/// <summary>
 4/// Configuration settings for forwarded headers support.
 5/// </summary>
 6public sealed class ApplicationForwardedHeadersOptions
 7{
 8    /// <summary>
 9    /// Configuration section name for forwarded headers settings.
 10    /// </summary>
 11    public const string SectionName = "ProjectTemplate:ForwardedHeaders";
 12
 13    /// <summary>
 14    /// Enables or disables forwarded headers middleware.
 15    /// </summary>
 134416    public bool Enabled { get; set; } = true;
 17
 18    /// <summary>
 19    /// Gets or sets a value indicating whether startup must fail outside Development when forwarded
 20    /// client IP processing and rate limiting are enabled without an explicitly configured trusted proxy or network.
 21    /// </summary>
 103022    public bool RequireExplicitProxyTrust { get; set; }
 23
 24    /// <summary>
 25    /// Forwarded header values to process.
 26    /// Valid values include XForwardedFor, XForwardedProto, XForwardedHost, and XForwardedPrefix.
 27    /// </summary>
 179028    public string[] Headers { get; set; } =
 45629    [
 45630        "XForwardedFor",
 45631        "XForwardedProto"
 45632    ];
 33
 34    /// <summary>
 35    /// Limits the number of forwarded header entries processed.
 36    /// Keep this low unless the proxy chain is well understood.
 37    /// </summary>
 135438    public int? ForwardLimit { get; set; } = 1;
 39
 40    /// <summary>
 41    /// Requires the number of values to match across forwarded headers.
 42    /// </summary>
 59643    public bool RequireHeaderSymmetry { get; set; }
 44
 45    /// <summary>
 46    /// Clears default known proxies/networks before applying configured values.
 47    /// For production, set this to true and explicitly configure trusted proxies/networks.
 48    /// </summary>
 59649    public bool ClearKnownNetworksAndProxies { get; set; }
 50
 51    /// <summary>
 52    /// Exact proxy IP addresses trusted to send forwarded headers.
 53    /// </summary>
 194254    public string[] KnownProxies { get; set; } = [];
 55
 56    /// <summary>
 57    /// Trusted proxy networks in CIDR notation.
 58    /// Example: 10.0.0.0/24
 59    /// </summary>
 193260    public string[] KnownNetworks { get; set; } = [];
 61
 62    /// <summary>
 63    /// Allowed host values from X-Forwarded-Host.
 64    /// Only needed when XForwardedHost is enabled.
 65    /// </summary>
 150666    public string[] AllowedHosts { get; set; } = [];
 67}