< Summary - Kestrun — Combined Coverage

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

#LineLine coverage
 1<#
 2    .SYNOPSIS
 3        Adds a new claim policy to the KestrunClaims system.
 4    .DESCRIPTION
 5        This function allows you to define a new claim policy by specifying the policy name, claim type, and allowed val
 6    .PARAMETER Builder
 7        The claim policy builder instance used to create the policy.
 8    .PARAMETER PolicyName
 9        The name of the policy to be created.
 10    .PARAMETER ClaimType
 11        The type of claim being defined.
 12    .PARAMETER UserClaimType
 13        The user identity claim type.
 14    .PARAMETER AllowedValues
 15        The values that are allowed for this claim.
 16    .EXAMPLE
 17        PS C:\> Add-KrClaimPolicy -Builder $builder -PolicyName "ExamplePolicy" -ClaimType "ExampleClaim" -AllowedValues
 18        This is an example of how to use the Add-KrClaimPolicy function.
 19    .NOTES
 20        This function is part of the Kestrun.Jwt module and is used to build Claims
 21#>
 22function Add-KrClaimPolicy {
 23    [KestrunRuntimeApi('Everywhere')]
 24    [CmdletBinding(DefaultParameterSetName = 'ClaimType')]
 25    [OutputType([Kestrun.Claims.ClaimPolicyBuilder])]
 26    param(
 27        [Parameter(Mandatory = $true, ValueFromPipeline)]
 28        [Kestrun.Claims.ClaimPolicyBuilder] $Builder,
 29        [Parameter(Mandatory = $true)]
 30        [string] $PolicyName,
 31        [Parameter(Mandatory = $true, ParameterSetName = 'ClaimType')]
 32        [string] $ClaimType,
 33        [Parameter(Mandatory = $true, ParameterSetName = 'UserClaimType')]
 34        [Kestrun.Claims.UserIdentityClaim] $UserClaimType,
 35        [Parameter(Mandatory = $true)]
 36        [string[]] $AllowedValues
 37    )
 38    begin {
 139        if ($UserClaimType) {
 140            $ClaimType = [Kestrun.Claims.KestrunClaimExtensions]::ToClaimUri($UserClaimType)
 41        }
 42    }
 43    process {
 144        return $Builder.AddPolicy($PolicyName, $ClaimType, $AllowedValues)
 45    }
 46}
 47

Methods/Properties

Add-KrClaimPolicy()