Test-KrJWT

SYNOPSIS

Validates a JWT token against the builder’s parameters.

SYNTAX

Test-KrJWT [-Result] <JwtBuilderResult> [-Token] <String> [[-ClockSkew] <TimeSpan>] [<CommonParameters>]

DESCRIPTION

This function validates a JWT token against the parameters set in the JWT builder, checking for expiration, issuer, audience, and other claims.

EXAMPLES

EXAMPLE 1

$isValid = New-KrJWTTokenBuilder | Add-KrJWTSubject -Subject "mySubject" | Build-KrJWT | Test-KrJWT -Token $token
This example creates a new JWT token builder, adds a subject, and then tests the validity of the JWT token.

PARAMETERS

-Result

The JWT builder result containing the token and validation parameters.

Type: JwtBuilderResult
Parameter Sets: (All)
Aliases:

Required: True
Position: 1
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False

-Token

The JWT token to validate.

Type: String
Parameter Sets: (All)
Aliases:

Required: True
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-ClockSkew

The allowed clock skew for validation, defaulting to 1 minute.

Type: TimeSpan
Parameter Sets: (All)
Aliases:

Required: False
Position: 3
Default value: ([TimeSpan]::FromMinutes(1))
Accept pipeline input: False
Accept wildcard characters: False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

INPUTS

OUTPUTS

[bool]

Returns true if the token is valid, otherwise false.

NOTES

This function is part of the Kestrun.Jwt module and is used to validate JWT tokens. Maps to JwtBuilderResult.Validate