< Summary - Kestrun — Combined Coverage

Information
Class: Kestrun.Authentication.OidcOptions
Assembly: Kestrun
File(s): /home/runner/work/Kestrun/Kestrun/src/CSharp/Kestrun/Authentication/OidcOptions.cs
Tag: Kestrun/Kestrun@5f1d2b981c9d7292c11fd448428c6ab6c811c5de
Line coverage
93%
Covered lines: 101
Uncovered lines: 7
Coverable lines: 108
Total lines: 260
Line coverage: 93.5%
Branch coverage
67%
Covered branches: 23
Total branches: 34
Branch coverage: 67.6%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100 11/19/2025 - 17:40:50 Line coverage: 93.7% (90/96) Branch coverage: 76.6% (23/30) Total lines: 216 Tag: Kestrun/Kestrun@fcf33342333cef0516fe0d0912a86709874fd02612/12/2025 - 17:27:19 Line coverage: 92.5% (99/107) Branch coverage: 67.6% (23/34) Total lines: 256 Tag: Kestrun/Kestrun@826bf9dcf9db118c5de4c78a3259bce9549f0dcd12/15/2025 - 02:23:46 Line coverage: 92.1% (94/102) Branch coverage: 63.3% (19/30) Total lines: 256 Tag: Kestrun/Kestrun@7a3839f4de2254e22daae81ab8dc7cb2f40c833012/21/2025 - 06:07:10 Line coverage: 91.2% (94/103) Branch coverage: 63.3% (19/30) Total lines: 260 Tag: Kestrun/Kestrun@8cf7f77e55fd1fd046ea4e5413eb9ef96e49fe6a03/26/2026 - 03:54:59 Line coverage: 93.5% (101/108) Branch coverage: 67.6% (23/34) Total lines: 260 Tag: Kestrun/Kestrun@844b5179fb0492dc6b1182bae3ff65fa7365521d 11/19/2025 - 17:40:50 Line coverage: 93.7% (90/96) Branch coverage: 76.6% (23/30) Total lines: 216 Tag: Kestrun/Kestrun@fcf33342333cef0516fe0d0912a86709874fd02612/12/2025 - 17:27:19 Line coverage: 92.5% (99/107) Branch coverage: 67.6% (23/34) Total lines: 256 Tag: Kestrun/Kestrun@826bf9dcf9db118c5de4c78a3259bce9549f0dcd12/15/2025 - 02:23:46 Line coverage: 92.1% (94/102) Branch coverage: 63.3% (19/30) Total lines: 256 Tag: Kestrun/Kestrun@7a3839f4de2254e22daae81ab8dc7cb2f40c833012/21/2025 - 06:07:10 Line coverage: 91.2% (94/103) Branch coverage: 63.3% (19/30) Total lines: 260 Tag: Kestrun/Kestrun@8cf7f77e55fd1fd046ea4e5413eb9ef96e49fe6a03/26/2026 - 03:54:59 Line coverage: 93.5% (101/108) Branch coverage: 67.6% (23/34) Total lines: 260 Tag: Kestrun/Kestrun@844b5179fb0492dc6b1182bae3ff65fa7365521d

Coverage delta

Coverage delta 9 -9

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_CookieOptions()100%11100%
get_CookieScheme()100%22100%
get_JwkJson()100%11100%
get_GlobalScheme()100%11100%
get_Description()100%11100%
get_DisplayName()100%11100%
get_DocumentationId()100%11100%
get_Host()100%11100%
get_Logger()0%2040%
.ctor()100%11100%
get_AuthenticationScheme()100%11100%
get_ClaimPolicy()100%11100%
get_Deprecated()100%11100%
ApplyTo(...)100%11100%
ApplyTo(...)100%11100%
CopyCoreEndpoints(...)100%11100%
CopyFlowConfiguration(...)100%11100%
CopyScopes(...)100%22100%
CopyTokenHandling(...)100%11100%
CopyPaths(...)100%11100%
CopyTokenValidation(...)100%22100%
CopySchemeLinkage(...)100%11100%
CopyBackchannelConfiguration(...)66.67%7671.43%
CopyConfiguration(...)50%5460%
CopyClaimActions(...)66.67%6685.71%
CopyEvents(...)75%4480%
CopyIssuerAndProperties(...)100%11100%
CopyNet9Features(...)100%44100%

File(s)

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

#LineLine coverage
 1using Kestrun.Claims;
 2using Kestrun.Hosting;
 3using Microsoft.AspNetCore.Authentication;
 4using Microsoft.AspNetCore.Authentication.Cookies;
 5using Microsoft.AspNetCore.Authentication.OpenIdConnect;
 6
 7namespace Kestrun.Authentication;
 8
 9/// <summary>
 10/// Options for OpenID Connect authentication.
 11/// </summary>
 12public class OidcOptions : OpenIdConnectOptions, IOpenApiAuthenticationOptions, IAuthenticationHostOptions, IOAuthCommon
 13{
 14    /// <summary>
 15    /// Options for cookie authentication.
 16    /// </summary>
 717    public CookieAuthOptions CookieOptions { get; }
 18
 19    /// <summary>
 20    /// Gets the cookie authentication scheme name.
 21    /// </summary>
 22    public string CookieScheme =>
 423    CookieOptions.Cookie.Name ?? (CookieAuthenticationDefaults.AuthenticationScheme + "." + AuthenticationScheme);
 24
 25    /// <summary>
 26    /// JSON Web Key (JWK) for token validation.
 27    /// </summary>
 1028    public string? JwkJson { get; set; }
 29
 30#if NET8_0
 31    /// <summary>
 32    /// Additional authorization parameters to include in the authorization request.
 33    /// </summary>
 34    public string PushedAuthorizationBehavior { get; set; } = "Disable";
 35#endif
 36
 37    /// <inheritdoc/>
 338    public bool GlobalScheme { get; set; }
 39
 40    /// <inheritdoc/>
 341    public string? Description { get; set; }
 42
 43    /// <inheritdoc/>
 244    public string? DisplayName { get; set; }
 45
 46    /// <inheritdoc/>
 2047    public string[] DocumentationId { get; set; } = [];
 48
 49    /// <inheritdoc/>
 50#pragma warning disable IDE0370 // Remove unnecessary suppression
 451    public KestrunHost Host { get; set; } = default!;
 52#pragma warning restore IDE0370 // Remove unnecessary suppression
 53
 54    private Serilog.ILogger? _logger;
 55    /// <inheritdoc/>
 56    public Serilog.ILogger Logger
 57    {
 058        get => _logger ?? (Host is null ? Serilog.Log.Logger : Host.Logger); set => _logger = value;
 59    }
 60
 61    /// <summary>
 62    /// Initializes a new instance of the <see cref="OidcOptions"/> class.
 63    /// </summary>
 1464    public OidcOptions()
 65    {
 1466        CookieOptions = new CookieAuthOptions()
 1467        {
 1468            SlidingExpiration = true
 1469        };
 1470    }
 71
 72    /// <summary>
 73    /// Gets or sets the authentication scheme name.
 74    /// </summary>
 2075    public string AuthenticationScheme { get; set; } = AuthenticationDefaults.OidcSchemeName;
 76
 77    /// <summary>
 78    /// Configuration for claim policy enforcement.
 79    /// </summary>
 580    public ClaimPolicyConfig? ClaimPolicy { get; set; }
 81
 82    /// <inheritdoc/>
 183    public bool Deprecated { get; set; }
 84
 85    /// <summary>
 86    /// Helper to copy values from a user-supplied OidcOptions instance to the instance
 87    /// created by the framework inside AddOpenIdConnect().
 88    /// </summary>
 89    /// <param name="target">The target options to copy to.</param>
 90    public void ApplyTo(OidcOptions target)
 91    {
 292        ApplyTo((OpenIdConnectOptions)target);
 193        target.JwkJson = JwkJson;
 94        // OpenAPI / documentation properties
 195        target.GlobalScheme = GlobalScheme;
 196        target.Description = Description;
 197        target.DisplayName = DisplayName;
 198        target.DocumentationId = DocumentationId;
 199        target.Host = Host;
 1100    }
 101
 102    /// <summary>
 103    /// Helper to copy values from a user-supplied OpenIdConnectOptions instance to the instance
 104    /// created by the framework inside AddOpenIdConnect().
 105    /// </summary>
 106    /// <param name="target">The target options to copy to.</param>
 107    public void ApplyTo(OpenIdConnectOptions target)
 108    {
 10109        CopyCoreEndpoints(target);
 8110        CopyFlowConfiguration(target);
 8111        CopyScopes(target);
 8112        CopyTokenHandling(target);
 8113        CopyPaths(target);
 8114        CopyTokenValidation(target);
 8115        CopySchemeLinkage(target);
 8116        CopyBackchannelConfiguration(target);
 8117        CopyConfiguration(target);
 8118        CopyClaimActions(target);
 8119        CopyEvents(target);
 8120        CopyIssuerAndProperties(target);
 121#if NET9_0_OR_GREATER
 8122        CopyNet9Features(target);
 123#endif
 8124    }
 125
 126    private void CopyCoreEndpoints(OpenIdConnectOptions target)
 127    {
 10128        target.Authority = Authority;
 8129        target.ClientId = ClientId;
 8130        target.ClientSecret = ClientSecret;
 8131    }
 132
 133    private void CopyFlowConfiguration(OpenIdConnectOptions target)
 134    {
 8135        target.ResponseType = ResponseType;
 8136        target.ResponseMode = ResponseMode;
 8137        target.UsePkce = UsePkce;
 8138        target.RequireHttpsMetadata = RequireHttpsMetadata;
 8139    }
 140
 141    private void CopyScopes(OpenIdConnectOptions target)
 142    {
 8143        target.Scope.Clear();
 50144        foreach (var scope in Scope)
 145        {
 17146            target.Scope.Add(scope);
 147        }
 8148    }
 149
 150    private void CopyTokenHandling(OpenIdConnectOptions target)
 151    {
 8152        target.SaveTokens = SaveTokens;
 8153        target.GetClaimsFromUserInfoEndpoint = GetClaimsFromUserInfoEndpoint;
 8154        target.MapInboundClaims = MapInboundClaims;
 8155        target.UseSecurityTokenValidator = UseSecurityTokenValidator;
 8156    }
 157
 158    private void CopyPaths(OpenIdConnectOptions target)
 159    {
 8160        target.CallbackPath = CallbackPath;
 8161        target.SignedOutCallbackPath = SignedOutCallbackPath;
 8162        target.SignedOutRedirectUri = SignedOutRedirectUri;
 8163        target.RemoteSignOutPath = RemoteSignOutPath;
 8164    }
 165
 166    private void CopyTokenValidation(OpenIdConnectOptions target)
 167    {
 8168        if (TokenValidationParameters != null)
 169        {
 8170            target.TokenValidationParameters = TokenValidationParameters;
 171        }
 8172    }
 173
 174    private void CopySchemeLinkage(OpenIdConnectOptions target)
 175    {
 8176        target.SignInScheme = SignInScheme;
 8177        target.SignOutScheme = SignOutScheme;
 8178    }
 179
 180    private void CopyBackchannelConfiguration(OpenIdConnectOptions target)
 181    {
 8182        if (Backchannel != null)
 183        {
 0184            target.Backchannel = Backchannel;
 185        }
 8186        if (BackchannelHttpHandler != null)
 187        {
 0188            target.BackchannelHttpHandler = BackchannelHttpHandler;
 189        }
 8190        if (BackchannelTimeout != default)
 191        {
 8192            target.BackchannelTimeout = BackchannelTimeout;
 193        }
 8194    }
 195
 196    private void CopyConfiguration(OpenIdConnectOptions target)
 197    {
 8198        if (Configuration != null)
 199        {
 0200            target.Configuration = Configuration;
 201        }
 8202        if (ConfigurationManager != null)
 203        {
 0204            target.ConfigurationManager = ConfigurationManager;
 205        }
 8206    }
 207
 208    private void CopyClaimActions(OpenIdConnectOptions target)
 209    {
 8210        if (ClaimActions == null)
 211        {
 0212            return;
 213        }
 116214        foreach (var jka in ClaimActions
 8215            .OfType<Microsoft.AspNetCore.Authentication.OAuth.Claims.JsonKeyClaimAction>()
 58216            .Where(a => !string.IsNullOrEmpty(a.JsonKey) && !string.IsNullOrEmpty(a.ClaimType)))
 217        {
 50218            target.ClaimActions.MapJsonKey(jka.ClaimType, jka.JsonKey);
 219        }
 8220    }
 221
 222    private void CopyEvents(OpenIdConnectOptions target)
 223    {
 8224        if (Events != null)
 225        {
 8226            target.Events = Events;
 227        }
 8228        if (EventsType != null)
 229        {
 0230            target.EventsType = EventsType;
 231        }
 8232    }
 233
 234    private void CopyIssuerAndProperties(OpenIdConnectOptions target)
 235    {
 8236        target.ClaimsIssuer = ClaimsIssuer;
 8237        target.DisableTelemetry = DisableTelemetry;
 8238        target.MaxAge = MaxAge;
 8239        target.ProtocolValidator = ProtocolValidator;
 8240        target.RefreshOnIssuerKeyNotFound = RefreshOnIssuerKeyNotFound;
 8241        target.Resource = Resource;
 8242        target.SkipUnrecognizedRequests = SkipUnrecognizedRequests;
 8243        target.StateDataFormat = StateDataFormat;
 8244        target.StringDataFormat = StringDataFormat;
 8245    }
 246
 247#if NET9_0_OR_GREATER
 248    private void CopyNet9Features(OpenIdConnectOptions target)
 249    {
 8250        target.PushedAuthorizationBehavior = PushedAuthorizationBehavior;
 8251        if (AdditionalAuthorizationParameters != null)
 252        {
 20253            foreach (var param in AdditionalAuthorizationParameters)
 254            {
 2255                target.AdditionalAuthorizationParameters[param.Key] = param.Value;
 256            }
 257        }
 8258    }
 259#endif
 260}

Methods/Properties

get_CookieOptions()
get_CookieScheme()
get_JwkJson()
get_GlobalScheme()
get_Description()
get_DisplayName()
get_DocumentationId()
get_Host()
get_Logger()
.ctor()
get_AuthenticationScheme()
get_ClaimPolicy()
get_Deprecated()
ApplyTo(Kestrun.Authentication.OidcOptions)
ApplyTo(Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectOptions)
CopyCoreEndpoints(Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectOptions)
CopyFlowConfiguration(Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectOptions)
CopyScopes(Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectOptions)
CopyTokenHandling(Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectOptions)
CopyPaths(Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectOptions)
CopyTokenValidation(Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectOptions)
CopySchemeLinkage(Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectOptions)
CopyBackchannelConfiguration(Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectOptions)
CopyConfiguration(Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectOptions)
CopyClaimActions(Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectOptions)
CopyEvents(Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectOptions)
CopyIssuerAndProperties(Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectOptions)
CopyNet9Features(Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectOptions)