en-US/PoshJsonWebToken.dll-Help.xml
<?xml version="1.0" encoding="utf-8"?> <helpItems schema="maml" xmlns="http://msh"> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>New-JsonWebToken</command:name> <command:verb>New</command:verb> <command:noun>JsonWebToken</command:noun> <maml:description> <maml:para>Creates a signed or encrypted Json Web Token (JWT).</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The `New-JsonWebToken` cmdlet can be used to create a new signed or encrypted Json Web Token (JWT) using a secret key or certificate.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>New-JsonWebToken</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Algorithm</maml:name> <maml:description> <maml:para>The JWS (Json Web Signature) or JWE (Json Web Encryption) hash algorithm. If `none` JWS algorithm is used, a warning message is displayed indicating plain text algorithm is used without integrity protection.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">String</command:parameterValue> <dev:type> <maml:name>String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Certificate</maml:name> <maml:description> <maml:para>The certificate used for signing or encryption.</maml:para> <maml:para>Supported JWS (Json Web Signature) algorithms:</maml:para> <maml:para>+ `RS256` + `RS384` + `RS512` + `ES256` + `ES384` + `ES512`</maml:para> <maml:para>Supported JWE (Json Web Encryption) algorithms:</maml:para> <maml:para>+ `RSA_OAEP_256` + `RSA_OAEP` + `RSA1_5`</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">X509Certificate2</command:parameterValue> <dev:type> <maml:name>X509Certificate2</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Encryption</maml:name> <maml:description> <maml:para>The encryption used for JWE (Json Web Encryption) JWT tokens.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">String</command:parameterValue> <dev:type> <maml:name>String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>ExtraHeader</maml:name> <maml:description> <maml:para>The extra headers needed to sign JWT token. These headers are not including the `alg` header which is passed using `-Algorithm` parameter and `enc` header which is passed using `-Encryption` parameter.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">Hashtable</command:parameterValue> <dev:type> <maml:name>Hashtable</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Payload</maml:name> <maml:description> <maml:para>The payload containing the claims to sign.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">Hashtable</command:parameterValue> <dev:type> <maml:name>Hashtable</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>New-JsonWebToken</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Algorithm</maml:name> <maml:description> <maml:para>The JWS (Json Web Signature) or JWE (Json Web Encryption) hash algorithm. If `none` JWS algorithm is used, a warning message is displayed indicating plain text algorithm is used without integrity protection.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">String</command:parameterValue> <dev:type> <maml:name>String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Encryption</maml:name> <maml:description> <maml:para>The encryption used for JWE (Json Web Encryption) JWT tokens.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">String</command:parameterValue> <dev:type> <maml:name>String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>ExtraHeader</maml:name> <maml:description> <maml:para>The extra headers needed to sign JWT token. These headers are not including the `alg` header which is passed using `-Algorithm` parameter and `enc` header which is passed using `-Encryption` parameter.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">Hashtable</command:parameterValue> <dev:type> <maml:name>Hashtable</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Payload</maml:name> <maml:description> <maml:para>The payload containing the claims to sign.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">Hashtable</command:parameterValue> <dev:type> <maml:name>Hashtable</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>SecretKey</maml:name> <maml:description> <maml:para>The secret secret key used for signing or encryption.</maml:para> <maml:para>Supported JWS (Json Web Signature) algorithms:</maml:para> <maml:para>+ `HS256` + `HS384` + `HS512`</maml:para> <maml:para>Supported JWE (Json Web Encryption) algorithms:</maml:para> <maml:para>+ `DIR` + `A128KW` + `A192KW` + `A256KW` + `A128GCMKW` + `A192GCMKW` + `A256GCMKW` + `PBES2_HS256_A128KW` + `PBES2_HS384_A192KW` + `PBES2_HS512_A256KW`</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">SecureString</command:parameterValue> <dev:type> <maml:name>SecureString</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Algorithm</maml:name> <maml:description> <maml:para>The JWS (Json Web Signature) or JWE (Json Web Encryption) hash algorithm. If `none` JWS algorithm is used, a warning message is displayed indicating plain text algorithm is used without integrity protection.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">String</command:parameterValue> <dev:type> <maml:name>String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Certificate</maml:name> <maml:description> <maml:para>The certificate used for signing or encryption.</maml:para> <maml:para>Supported JWS (Json Web Signature) algorithms:</maml:para> <maml:para>+ `RS256` + `RS384` + `RS512` + `ES256` + `ES384` + `ES512`</maml:para> <maml:para>Supported JWE (Json Web Encryption) algorithms:</maml:para> <maml:para>+ `RSA_OAEP_256` + `RSA_OAEP` + `RSA1_5`</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">X509Certificate2</command:parameterValue> <dev:type> <maml:name>X509Certificate2</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Encryption</maml:name> <maml:description> <maml:para>The encryption used for JWE (Json Web Encryption) JWT tokens.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">String</command:parameterValue> <dev:type> <maml:name>String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>ExtraHeader</maml:name> <maml:description> <maml:para>The extra headers needed to sign JWT token. These headers are not including the `alg` header which is passed using `-Algorithm` parameter and `enc` header which is passed using `-Encryption` parameter.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">Hashtable</command:parameterValue> <dev:type> <maml:name>Hashtable</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Payload</maml:name> <maml:description> <maml:para>The payload containing the claims to sign.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">Hashtable</command:parameterValue> <dev:type> <maml:name>Hashtable</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>SecretKey</maml:name> <maml:description> <maml:para>The secret secret key used for signing or encryption.</maml:para> <maml:para>Supported JWS (Json Web Signature) algorithms:</maml:para> <maml:para>+ `HS256` + `HS384` + `HS512`</maml:para> <maml:para>Supported JWE (Json Web Encryption) algorithms:</maml:para> <maml:para>+ `DIR` + `A128KW` + `A192KW` + `A256KW` + `A128GCMKW` + `A192GCMKW` + `A256GCMKW` + `PBES2_HS256_A128KW` + `PBES2_HS384_A192KW` + `PBES2_HS512_A256KW`</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">SecureString</command:parameterValue> <dev:type> <maml:name>SecureString</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>None</maml:name> </dev:type> <maml:description> <maml:para></maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>System.Security.SecureString</maml:name> </dev:type> <maml:description> <maml:para>Output is secured so Json Web Token (JWT) encrypyted string is not exposed.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para></maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>-------------------------- Example 1 --------------------------</maml:title> <dev:code>$payload = @{ 'a' = 'b' } $header = @{ 'exp' = 1300819380 } $secretKey = 'abc' | ConvertTo-SecureString -AsPlainText -Force $algorithm = 'HS256' # Generate JWT token $token = New-JsonWebToken -Payload $Payload -Algorithm $algorithm -SecretKey $SecretKey -ExtraHeader $header</dev:code> <dev:remarks> <maml:para>Creating a HS256 JWT token using secret key.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>-------------------------- Example 2 --------------------------</maml:title> <dev:code>$payload = @{ 'a' = 'b' } $header = @{ 'exp' = 1300819380 } $algorithm = 'RS256' $certificatePath = Resolve-Path -Path 'cert.p12' $certificate = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2($certificatePath) # Generate JWT token $token = New-JsonWebToken -Payload $Payload -Algorithm $algorithm -Certificate $certificate -ExtraHeader $header</dev:code> <dev:remarks> <maml:para>Creating a RS256 JWT token using certificate.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>-------------------------- Example 3 --------------------------</maml:title> <dev:code>$payload = @{ 'a' = 'b' } $header = @{ 'exp' = 1300819380 } $algorithm = 'RSA_OAEP' $encryption = 'A256GCM' $certificatePath = Resolve-Path -Path 'cert.p12' $certificate = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2($certificatePath) # Generate JWT token $token = New-JsonWebToken -Payload $Payload -Algorithm $algorithm -Encryption $encryption -Certificate $certificate -ExtraHeader $header # Validate JWT token Test-JsonWebToken -Token $token -Certificate $certificate -Algorithm $algorithm -Encryption $encryption</dev:code> <dev:remarks> <maml:para>Creating a RSA_OAEP encrypted JWT token with A256GCM using certificate.</maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks /> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Test-JsonWebToken</command:name> <command:verb>Test</command:verb> <command:noun>JsonWebToken</command:noun> <maml:description> <maml:para>Tests signed or encrypted Json Web Token (JWT) is valid.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The `Test-JsonWebToken` cmdlet can be used to ensure Json Web Token (JWT) is valid.</maml:para> <maml:para>This cmdlet also ensures strict validation is performed on the Json Web Token (JWT). This means that you will specify which algorithm and/or encryption you are expecting to receive in the header.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Test-JsonWebToken</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Algorithm</maml:name> <maml:description> <maml:para>The JWS (Json Web Signature) or JWE (Json Web Encryption) hash algorithm. If `none` JWS algorithm is used, a warning message is displayed indicating plain text algorithm is used without integrity protection.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">String</command:parameterValue> <dev:type> <maml:name>String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Certificate</maml:name> <maml:description> <maml:para>The certificate used for signing or encryption.</maml:para> <maml:para>Supported JWS (Json Web Signature) algorithms:</maml:para> <maml:para>+ `RS256` + `RS384` + `RS512` + `ES256` + `ES384` + `ES512`</maml:para> <maml:para>Supported JWE (Json Web Encryption) algorithms:</maml:para> <maml:para>+ `RSA_OAEP_256` + `RSA_OAEP` + `RSA1_5`</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">X509Certificate2</command:parameterValue> <dev:type> <maml:name>X509Certificate2</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Encryption</maml:name> <maml:description> <maml:para>The encryption used for JWE (Json Web Encryption) JWT tokens.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">String</command:parameterValue> <dev:type> <maml:name>String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Token</maml:name> <maml:description> <maml:para>The signed or encrypted JWT token to validate.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">SecureString</command:parameterValue> <dev:type> <maml:name>SecureString</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Test-JsonWebToken</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Algorithm</maml:name> <maml:description> <maml:para>The JWS (Json Web Signature) or JWE (Json Web Encryption) hash algorithm. If `none` JWS algorithm is used, a warning message is displayed indicating plain text algorithm is used without integrity protection.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">String</command:parameterValue> <dev:type> <maml:name>String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Encryption</maml:name> <maml:description> <maml:para>The encryption used for JWE (Json Web Encryption) JWT tokens.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">String</command:parameterValue> <dev:type> <maml:name>String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>SecretKey</maml:name> <maml:description> <maml:para>The secret secret key used for signing or encryption.</maml:para> <maml:para>Supported JWS (Json Web Signature) algorithms:</maml:para> <maml:para>+ `HS256` + `HS384` + `HS512`</maml:para> <maml:para>Supported JWE (Json Web Encryption) algorithms:</maml:para> <maml:para>+ `DIR` + `A128KW` + `A192KW` + `A256KW` + `A128GCMKW` + `A192GCMKW` + `A256GCMKW` + `PBES2_HS256_A128KW` + `PBES2_HS384_A192KW` + `PBES2_HS512_A256KW`</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">SecureString</command:parameterValue> <dev:type> <maml:name>SecureString</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Token</maml:name> <maml:description> <maml:para>The signed or encrypted JWT token to validate.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">SecureString</command:parameterValue> <dev:type> <maml:name>SecureString</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Algorithm</maml:name> <maml:description> <maml:para>The JWS (Json Web Signature) or JWE (Json Web Encryption) hash algorithm. If `none` JWS algorithm is used, a warning message is displayed indicating plain text algorithm is used without integrity protection.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">String</command:parameterValue> <dev:type> <maml:name>String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Certificate</maml:name> <maml:description> <maml:para>The certificate used for signing or encryption.</maml:para> <maml:para>Supported JWS (Json Web Signature) algorithms:</maml:para> <maml:para>+ `RS256` + `RS384` + `RS512` + `ES256` + `ES384` + `ES512`</maml:para> <maml:para>Supported JWE (Json Web Encryption) algorithms:</maml:para> <maml:para>+ `RSA_OAEP_256` + `RSA_OAEP` + `RSA1_5`</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">X509Certificate2</command:parameterValue> <dev:type> <maml:name>X509Certificate2</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Encryption</maml:name> <maml:description> <maml:para>The encryption used for JWE (Json Web Encryption) JWT tokens.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">String</command:parameterValue> <dev:type> <maml:name>String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>SecretKey</maml:name> <maml:description> <maml:para>The secret secret key used for signing or encryption.</maml:para> <maml:para>Supported JWS (Json Web Signature) algorithms:</maml:para> <maml:para>+ `HS256` + `HS384` + `HS512`</maml:para> <maml:para>Supported JWE (Json Web Encryption) algorithms:</maml:para> <maml:para>+ `DIR` + `A128KW` + `A192KW` + `A256KW` + `A128GCMKW` + `A192GCMKW` + `A256GCMKW` + `PBES2_HS256_A128KW` + `PBES2_HS384_A192KW` + `PBES2_HS512_A256KW`</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">SecureString</command:parameterValue> <dev:type> <maml:name>SecureString</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Token</maml:name> <maml:description> <maml:para>The signed or encrypted JWT token to validate.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">SecureString</command:parameterValue> <dev:type> <maml:name>SecureString</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>None</maml:name> </dev:type> <maml:description> <maml:para></maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>System.Boolean</maml:name> </dev:type> <maml:description> <maml:para>If JWT token is valid this cmdlet returns `True`, otherwise an exception is thrown and the cmdlet returns `False`.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para></maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>-------------------------- Example 1 --------------------------</maml:title> <dev:code>$payload = @{ 'a' = 'b' } $header = @{ 'exp' = 1300819380 } $secretKey = 'abc' | ConvertTo-SecureString -AsPlainText -Force $algorithm = 'HS256' # Generate JWT token $token = New-JsonWebToken -Payload $Payload -Algorithm $algorithm -SecretKey $SecretKey -ExtraHeader $header # Validate JWT token Test-JsonWebToken -Token $token -SecretKey $SecretKey -Algorithm $algorithm</dev:code> <dev:remarks> <maml:para>Validates signed JWT token using secret key and HS256 algorithm.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>-------------------------- Example 2 --------------------------</maml:title> <dev:code>$payload = @{ 'a' = 'b' } $header = @{ 'exp' = 1300819380 } $algorithm = 'RS256' $certificatePath = Resolve-Path -Path 'cert.p12' $certificate = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2($certificatePath) # Generate JWT token $token = New-JsonWebToken -Payload $Payload -Algorithm $algorithm -Certificate $certificate -ExtraHeader $header # Validate JWT token Test-JsonWebToken -Token $token -Certificate $certificate -Algorithm $algorithm</dev:code> <dev:remarks> <maml:para>Validates signed JWT token using certificate and RS256 algorithm.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>-------------------------- Example 3 --------------------------</maml:title> <dev:code>$payload = @{ 'a' = 'b' } $header = @{ 'exp' = 1300819380 } $algorithm = 'RSA_OAEP' $encryption = 'A256GCM' $certificatePath = Resolve-Path -Path 'cert.p12' $certificate = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2($certificatePath) # Generate JWT token $token = New-JsonWebToken -Payload $Payload -Algorithm $algorithm -Encryption $encryption -Certificate $certificate -ExtraHeader $header # Validate JWT token Test-JsonWebToken -Token $token -Certificate $certificate -Algorithm $algorithm -Encryption $encryption</dev:code> <dev:remarks> <maml:para>Validating a RSA_OAEP encrypted JWT token with A256GCM using certificate.</maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks /> </command:command> </helpItems> |