Soenneker.Utils.Jwt 11.0.1549

Prefix Reserved
dotnet add package Soenneker.Utils.Jwt --version 11.0.1549
                    
NuGet\Install-Package Soenneker.Utils.Jwt -Version 11.0.1549
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Soenneker.Utils.Jwt" Version="11.0.1549" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Soenneker.Utils.Jwt" Version="11.0.1549" />
                    
Directory.Packages.props
<PackageReference Include="Soenneker.Utils.Jwt" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Soenneker.Utils.Jwt --version 11.0.1549
                    
#r "nuget: Soenneker.Utils.Jwt, 11.0.1549"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Soenneker.Utils.Jwt@11.0.1549
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Soenneker.Utils.Jwt&version=11.0.1549
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.Utils.Jwt&version=11.0.1549
                    
Install as a Cake Tool

alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image

alternate text is missing from this package README image Soenneker.Utils.Jwt

Creates and validates HS256 JWTs and validates Azure OpenID Connect tokens.

Installation

dotnet add package Soenneker.Utils.Jwt

Quick start

using Soenneker.Utils.Jwt.Registrars;

services.AddJwtUtilAsSingleton();

Then inject IJwtUtil wherever you need it.

Create and verify an HMAC token

Configure the default signing key and lifetime:

{
  "Jwt": {
    "SigningKey": "a-long-random-secret-kept-out-of-source-control",
    "LifetimeMinutes": 30
  }
}
string token = jwtUtil.Create(
    subject: userId,
    extraClaims: new Dictionary<string, object> { ["role"] = "admin" });

ClaimsPrincipal? principal = jwtUtil.Verify(token);

Create emits an HS256 token containing sub, jti, iat, nbf, and exp. Extra claim values are converted to strings, and reserved claims supplied through extraClaims are ignored. You can provide both signingKey and lifetime directly when configuration is unavailable.

Verify validates the signature and, by default, the expiration time with zero clock skew. It does not validate issuer or audience, so use it only where possession of the shared key is the intended trust boundary. Invalid or expired tokens return null.

Validate Azure OpenID Connect tokens

The Azure overloads require these configuration values:

{
  "Azure": {
    "AzureAd": {
      "ClientId": "expected-audience",
      "JwtIssuer": "https://login.microsoftonline.com/{tenant-id}/v2.0",
      "MetadataAddress": "https://login.microsoftonline.com/{tenant-id}/v2.0/.well-known/openid-configuration"
    }
  }
}
ClaimsPrincipal? principal = await jwtUtil.GetPrincipal(token, cancellationToken: cancellationToken);

This path validates the configured issuer, audience, signature, expiration, and rotating signing keys obtained from the HTTPS metadata endpoint. Invalid tokens return null; metadata retrieval errors are logged and also result in null from GetPrincipal. Requested cancellation propagates.

Other validation option

GetValidationParameters(audience, issuer, publicKey, exponent) builds parameters for a specific RSA public key. The modulus and exponent must be Base64Url encoded. It enables issuer, audience, signature, and lifetime validation with zero clock skew.

Product Compatible and additional computed target framework versions.
.NET net11.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Soenneker.Utils.Jwt:

Package Downloads
Soenneker.Utils.Test.AuthHandler

A custom test authentication handler that builds a ClaimsPrincipal from headers or a JWT to simulate authenticated users during integration tests.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
11.0.1549 181 11/11/2026
11.0.1548 66 11/11/2026
11.0.1547 111 11/11/2026
11.0.1546 133 11/11/2026
11.0.1545 70 11/11/2026
11.0.1544 162 11/11/2026
11.0.1543 85 11/10/2026
11.0.1542 676 11/3/2026
11.0.1541 154 11/3/2026
11.0.1540 169 11/2/2026
11.0.1539 298 10/27/2026
11.0.1538 186 10/26/2026
11.0.1537 181 10/26/2026
11.0.1535 95 10/26/2026
4.0.1534 163 10/25/2026
4.0.1533 751 10/15/2026
4.0.1532 102 10/14/2026
4.0.1531 145 10/14/2026
4.0.1528 240 10/14/2026
4.0.1522 239 10/13/2026
Loading failed

Updated Multiple NuGet packages