For the complete documentation index, see llms.txt. This page is also available as Markdown.

New-PSUAuthorizationClaim

Creates a new authorization claim.

SYNOPSIS

Creates a new authorization claim.

SYNTAX

New-PSUAuthorizationClaim -Type <String> -Value <String> [-ValueType <String>] [-Properties <Hashtable>]
 [-Issuer <String>] [<CommonParameters>]

DESCRIPTION

Creates a new authorization claim. This cmdlet should be used within the Set-PSUAuthenticationMethod script block to assign claims to the user being authenticated.

EXAMPLES

Example 1

Set-PSUAuthenticationMethod -ScriptBlock {
    param([PSCredential]$Credential)

    if ($Credential.UserName -eq 'admin')
    {
        New-PSUAuthenticationResult -Success -UserName 'admin' -Claims {
            New-PSUAuthorizationClaim -Type 'MyRole' -Value 'MyValue' -ValueType 'String' -Issuer 'Something'
        }
    }
    else 
    {
        New-PSUAuthenticationResult -ErrorMessage 'Hello'
    }
}

New-PSURole -Name 'CustomRole' -Policy {
    param($User)

    $User.HasClaim("MyRole", "MyValue")
}

Authenticates a user named 'admin' and adds a custom authorization claim. Authorization claims can be used in role policy scripts and are accessible in dashboards.

PARAMETERS

-Issuer

The issuer of the authorization claim.

-Properties

A hashtable of properties to include with the claim.

-Type

The type of claim.

-Value

The value of the claim.

-ValueType

The type of value for the claim.

CommonParameters

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

INPUTS

None

OUTPUTS

System.Object

NOTES

Last updated

Was this helpful?