< Summary - Kestrun — Combined Coverage

Information
Class: Kestrun.Authentication.CookieAuthOptions
Assembly: Kestrun
File(s): /home/runner/work/Kestrun/Kestrun/src/CSharp/Kestrun/Authentication/CookieAuthOptions.cs
Tag: Kestrun/Kestrun@0d738bf294e6281b936d031e1979d928007495ff
Line coverage
9%
Covered lines: 4
Uncovered lines: 40
Coverable lines: 44
Total lines: 109
Line coverage: 9%
Branch coverage
0%
Covered branches: 0
Total branches: 8
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100 12/12/2025 - 17:27:19 Line coverage: 9% (4/44) Branch coverage: 0% (0/8) Total lines: 109 Tag: Kestrun/Kestrun@826bf9dcf9db118c5de4c78a3259bce9549f0dcd 12/12/2025 - 17:27:19 Line coverage: 9% (4/44) Branch coverage: 0% (0/8) Total lines: 109 Tag: Kestrun/Kestrun@826bf9dcf9db118c5de4c78a3259bce9549f0dcd

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_AllowInsecureHttp()100%210%
get_DisplayName()100%210%
get_GlobalScheme()100%11100%
get_Description()100%11100%
get_DocumentationId()100%11100%
get_Host()100%11100%
get_Logger()0%2040%
ApplyTo(...)100%210%
ApplyTo(...)0%2040%

File(s)

/home/runner/work/Kestrun/Kestrun/src/CSharp/Kestrun/Authentication/CookieAuthOptions.cs

#LineLine coverage
 1using Kestrun.Hosting;
 2using Microsoft.AspNetCore.Authentication.Cookies;
 3
 4namespace Kestrun.Authentication;
 5
 6/// <summary>
 7/// Options for cookie-based authentication.
 8/// </summary>
 9public class CookieAuthOptions : CookieAuthenticationOptions, IOpenApiAuthenticationOptions, IAuthenticationHostOptions
 10{
 11    /// <summary>
 12    /// If true, allows cookie authentication over insecure HTTP connections.
 13    /// </summary>
 014    public bool AllowInsecureHttp { get; set; }
 15
 16    /// <inheritdoc/>
 017    public string? DisplayName { get; set; }
 18
 19    /// <inheritdoc/>
 220    public bool GlobalScheme { get; set; }
 21
 22    /// <inheritdoc/>
 223    public string? Description { get; set; }
 24
 25    /// <inheritdoc/>
 3326    public string[] DocumentationId { get; set; } = [];
 27
 28    /// <inheritdoc/>
 229    public KestrunHost Host { get; set; } = default!;
 30
 31    private Serilog.ILogger? _logger;
 32    /// <inheritdoc/>
 33    public Serilog.ILogger Logger
 34    {
 035        get => _logger ?? (Host is null ? Serilog.Log.Logger : Host.Logger); set => _logger = value;
 36    }
 37
 38    /// <summary>
 39    /// Helper to copy values from a user-supplied CookieAuthenticationOptions instance to the instance
 40    /// created by the framework inside AddCookie(). Reassigning the local variable (opts = source) would
 41    /// not work because only the local reference changes – the framework keeps the original instance.
 42    /// </summary>
 43    /// <param name="target">The target options to copy to.</param>
 44    /// <exception cref="ArgumentNullException">Thrown when source or target is null.</exception>
 45    /// <remarks>
 46    /// Only copies primitive properties and references. Does not clone complex objects like CookieBuilder.
 47    /// </remarks>
 48    public void ApplyTo(CookieAuthOptions target)
 49    {
 050        ApplyTo((CookieAuthenticationOptions)target);
 051        target.GlobalScheme = GlobalScheme;
 052        target.Description = Description;
 053        target.DocumentationId = DocumentationId;
 054        target.DisplayName = DisplayName;
 055        target.Host = Host;
 056    }
 57
 58    /// <summary>
 59    /// Helper to copy values from this CookieAuthOptions instance to a target CookieAuthenticationOptions instance.
 60    /// </summary>
 61    /// <param name="target">The target CookieAuthenticationOptions instance to copy values to.</param>
 62    public void ApplyTo(CookieAuthenticationOptions target)
 63    {
 64        // Paths & return URL
 065        target.LoginPath = LoginPath;
 066        target.LogoutPath = LogoutPath;
 067        target.AccessDeniedPath = AccessDeniedPath;
 068        target.ReturnUrlParameter = ReturnUrlParameter;
 69
 70        // Expiration & sliding behavior
 071        target.ExpireTimeSpan = ExpireTimeSpan;
 072        target.SlidingExpiration = SlidingExpiration;
 73
 74        // Cookie builder settings
 75        // (Cookie is always non-null; copy primitive settings)
 076        if (Cookie.Name is not null)
 77        {
 078            target.Cookie.Name = Cookie.Name;
 079            target.Cookie.Path = Cookie.Path;
 080            target.Cookie.Domain = Cookie.Domain;
 081            target.Cookie.HttpOnly = Cookie.HttpOnly;
 082            target.Cookie.SameSite = Cookie.SameSite;
 083            target.Cookie.SecurePolicy = Cookie.SecurePolicy;
 084            target.Cookie.IsEssential = Cookie.IsEssential;
 085            target.Cookie.MaxAge = Cookie.MaxAge;
 86        }
 87        // Forwarding
 088        target.ForwardAuthenticate = ForwardAuthenticate;
 089        target.ForwardChallenge = ForwardChallenge;
 090        target.ForwardDefault = ForwardDefault;
 091        target.ForwardDefaultSelector = ForwardDefaultSelector;
 092        target.ForwardForbid = ForwardForbid;
 093        target.ForwardSignIn = ForwardSignIn;
 094        target.ForwardSignOut = ForwardSignOut;
 95
 96        // Data protection / ticket / session
 097        target.TicketDataFormat = TicketDataFormat;
 098        target.DataProtectionProvider = DataProtectionProvider;
 099        target.SessionStore = SessionStore;
 100
 101        // Events & issuer
 0102        if (Events is not null)
 103        {
 0104            target.Events = Events;
 105        }
 0106        target.EventsType = EventsType;
 0107        target.ClaimsIssuer = ClaimsIssuer;
 0108    }
 109}