| | 1 | |
|
| | 2 | | <# |
| | 3 | | .SYNOPSIS |
| | 4 | | Sets the validity period for the JWT token. |
| | 5 | | .DESCRIPTION |
| | 6 | | This function sets the validity period for the JWT token, specifying how long the token will be valid. |
| | 7 | | .PARAMETER Builder |
| | 8 | | The JWT token builder to modify. |
| | 9 | | .PARAMETER Lifetime |
| | 10 | | The duration for which the JWT token will be valid. |
| | 11 | | .OUTPUTS |
| | 12 | | [Kestrun.Jwt.JwtTokenBuilder] |
| | 13 | | The modified JWT token builder. |
| | 14 | | .EXAMPLE |
| | 15 | | $builder = New-KrJWTTokenBuilder | Limit-KrJWTValidity -Lifetime (New-TimeSpan -Hours 1) |
| | 16 | | This example creates a new JWT token builder and sets its validity period to 1 hour. |
| | 17 | | .NOTES |
| | 18 | | This function is part of the Kestrun.Jwt module and is used to build JWT tokens |
| | 19 | | Maps to JwtTokenBuilder.ValidFor |
| | 20 | | .LINK |
| | 21 | | https://docs.microsoft.com/en-us/dotnet/api/system.identitymodel.tokens.jwt.jwtsecuritytoken |
| | 22 | | #> |
| | 23 | | function Limit-KrJWTValidity { |
| | 24 | | [KestrunRuntimeApi('Everywhere')] |
| | 25 | | [CmdletBinding()] |
| | 26 | | [OutputType([Kestrun.Jwt.JwtTokenBuilder])] |
| | 27 | | param( |
| | 28 | | [Parameter(Mandatory = $true, ValueFromPipeline)] |
| | 29 | | [Kestrun.Jwt.JwtTokenBuilder] $Builder, |
| | 30 | | [Parameter(Mandatory)] |
| | 31 | | [TimeSpan] $Lifetime |
| | 32 | | ) |
| | 33 | | process { |
| 0 | 34 | | return $Builder.ValidFor($Lifetime) |
| | 35 | | } |
| | 36 | | } |
| | 37 | |
|