< Summary - Kestrun — Combined Coverage

Information
Class: Public.JWT.Get-KrJWTValidationParameter
Assembly: Kestrun.PowerShell.Public
File(s): /home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Public/JWT/Get-KrJWTValidationParameter.ps1
Tag: Kestrun/Kestrun@9d3a582b2d63930269564a7591aa77ef297cadeb
Line coverage
100%
Covered lines: 2
Uncovered lines: 0
Coverable lines: 2
Total lines: 46
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

Coverage history

Coverage history 0 25 50 75 100

Metrics

File(s)

/home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Public/JWT/Get-KrJWTValidationParameter.ps1

#LineLine coverage
 1<#
 2    .SYNOPSIS
 3        Retrieves the validation parameters for a JWT token builder result.
 4    .DESCRIPTION
 5        This function extracts the validation parameters from a JWT builder result, which can be used for validating JWT
 6    .PARAMETER Result
 7        The JWT builder result containing the token to validate.
 8    .PARAMETER ClockSkew
 9        The allowed clock skew for validation, defaulting to 1 minute.
 10    .OUTPUTS
 11        [System.IdentityModel.Tokens.Jwt.TokenValidationParameters]
 12        The validation parameters extracted from the JWT builder result.
 13    .EXAMPLE
 14        $validationParams = Get-KrJWTValidationParameter -Result $tokenBuilderResult -ClockSkew (New-TimeSpan -Minutes 5
 15        This example retrieves the validation parameters from the specified JWT builder result with a clock skew of 5 mi
 16    .EXAMPLE
 17        $JwtKeyHex = "6f1a1ce2e8cc4a5685ad0e1d1f0b8c092b6dce4f7a08b1c2d3e4f5a6b7c8d9e0";
 18        $JwtTokenBuilder = New-KrJWTBuilder |
 19        Add-KrJWTIssuer    -Issuer   $issuer |
 20        Add-KrJWTAudience  -Audience $audience |
 21        Protect-KrJWT -HexadecimalKey $JwtKeyHex -Algorithm HS256
 22
 23        # Add a JWT bearer authentication scheme using the validation parameters
 24        Add-KrJWTBearerAuthentication -Name "JwtScheme" -Options (Build-KrJWT -Builder $JwtTokenBuilder | Get-KrJWTValid
 25        This example creates a JWT token builder, adds an issuer and audience, protects the JWT with a hexadecimal key, 
 26    .NOTES
 27        This function is part of the Kestrun.Jwt module and is used to manage JWT tokens.
 28        Maps to JwtBuilderResult.GetValidationParameters
 29    .LINK
 30        https://docs.microsoft.com/en-us/dotnet/api/system.identitymodel.tokens.jwt.jwtsecuritytoken
 31#>
 32function Get-KrJWTValidationParameter {
 33    [KestrunRuntimeApi('Everywhere')]
 34    [CmdletBinding()]
 35    [OutputType([bool])]
 36    param(
 37        [Parameter(Mandatory = $true, ValueFromPipeline)]
 38        [Kestrun.Jwt.JwtBuilderResult] $Result,
 39        [Parameter()]
 140        [TimeSpan] $ClockSkew = ([TimeSpan]::FromMinutes(1))
 41    )
 42    process {
 143        return $Result.GetValidationParameters($ClockSkew)
 44    }
 45}
 46

Methods/Properties

Get-KrJWTValidationParameter()