< Summary - Kestrun — Combined Coverage

Information
Class: Public.Authentication.Add-KrWindowsAuthentication
Assembly: Kestrun.PowerShell.Public
File(s): /home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Public/Authentication/Add-KrWindowsAuthentication.ps1
Tag: Kestrun/Kestrun@0d738bf294e6281b936d031e1979d928007495ff
Line coverage
0%
Covered lines: 0
Uncovered lines: 7
Coverable lines: 7
Total lines: 73
Line coverage: 0%
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

Coverage history

Coverage history 0 25 50 75 100 08/26/2025 - 14:53:17 Line coverage: 75% (3/4) Total lines: 43 Tag: Kestrun/Kestrun@78d1e497d8ba989d121b57aa39aa3c6b22de743109/04/2025 - 22:37:32 Line coverage: 75% (3/4) Total lines: 44 Tag: Kestrun/Kestrun@afb7aadc0a8a42bfa2b51ea62c8a6e2cf63faec609/08/2025 - 20:34:03 Line coverage: 66.6% (4/6) Total lines: 48 Tag: Kestrun/Kestrun@3790ee5884494a7a2a829344a47743e0bf492e7210/13/2025 - 16:52:37 Line coverage: 0% (0/4) Total lines: 44 Tag: Kestrun/Kestrun@10d476bee71c71ad215bb8ab59f219887b5b4a5e12/12/2025 - 17:27:19 Line coverage: 0% (0/7) Total lines: 73 Tag: Kestrun/Kestrun@826bf9dcf9db118c5de4c78a3259bce9549f0dcd

Metrics

File(s)

/home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Public/Authentication/Add-KrWindowsAuthentication.ps1

#LineLine coverage
 1<#
 2    .SYNOPSIS
 3        Adds Windows authentication to the Kestrun server.
 4    .DESCRIPTION
 5        Configures the Kestrun server to use Windows authentication for incoming requests.
 6        This allows the server to authenticate users based on their Windows credentials.
 7        This enables the server to use Kerberos or NTLM for authentication.
 8    .PARAMETER Server
 9        The Kestrun server instance to configure.
 10        If not specified, the current server instance is used.
 11    .PARAMETER AuthenticationScheme
 12        The name of the Windows authentication scheme (default is 'Negotiate').
 13    .PARAMETER DisplayName
 14        The display name for the authentication scheme.
 15    .PARAMETER Description
 16        A description of the Windows authentication scheme.
 17    .PARAMETER Options
 18        The Windows authentication options to configure.
 19        If not specified, default options are used.
 20    .PARAMETER PassThru
 21        If specified, returns the modified server instance after adding the authentication.
 22    .EXAMPLE
 23        Add-KrWindowsAuthentication -Server $myServer -PassThru
 24        This example adds Windows authentication to the specified Kestrun server instance and returns the modified insta
 25    .LINK
 26        https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.authentication.windowsauthentication?view=aspn
 27    .NOTES
 28        This cmdlet is used to configure Windows authentication for the Kestrun server, allowing you to secure your APIs
 29#>
 30function Add-KrWindowsAuthentication {
 31    [KestrunRuntimeApi('Definition')]
 32    [CmdletBinding(defaultParameterSetName = 'ItemsScriptBlock')]
 33    [OutputType([Kestrun.Hosting.KestrunHost])]
 34    param(
 35        [Parameter(Mandatory = $false, ValueFromPipeline)]
 36        [Kestrun.Hosting.KestrunHost]$Server,
 37
 38        [Parameter(Mandatory = $false)]
 39        [string]$AuthenticationScheme = [Kestrun.Authentication.AuthenticationDefaults]::WindowsSchemeName,
 40
 41        [Parameter()]
 42        [string]$DisplayName = [Kestrun.Authentication.AuthenticationDefaults]::WindowsDisplayName,
 43
 44        [Parameter(Mandatory = $false)]
 45        [string]$Description,
 46
 47        [Parameter(Mandatory = $false)]
 48        [Kestrun.Authentication.WindowsAuthOptions]$Options,
 49
 50        [Parameter()]
 51        [switch]$PassThru
 52    )
 53    begin {
 54        # Ensure the server instance is resolved
 055        $Server = Resolve-KestrunServer -Server $Server
 56    }
 57    process {
 058        if ( $null -eq $Options ) {
 59            # Build options from individual parameters if not provided
 060            $Options = [Kestrun.Authentication.WindowsAuthOptions]::new()
 61        }
 62
 063        if ($Description) { $Options.Description = $Description }
 64
 65        # Add Windows authentication to the server instance ---
 066        [Kestrun.Hosting.KestrunHostAuthnExtensions]::AddWindowsAuthentication($Server, $AuthenticationScheme, $DisplayN
 067        if ($PassThru.IsPresent) {
 68            # if the PassThru switch is specified, return the modified server instance
 069            return $Server
 70        }
 71    }
 72}
 73

Methods/Properties

Add-KrWindowsAuthentication()