ArturRios.Jwt
1.0.0
dotnet add package ArturRios.Jwt --version 1.0.0
NuGet\Install-Package ArturRios.Jwt -Version 1.0.0
<PackageReference Include="ArturRios.Jwt" Version="1.0.0" />
<PackageVersion Include="ArturRios.Jwt" Version="1.0.0" />
<PackageReference Include="ArturRios.Jwt" />
paket add ArturRios.Jwt --version 1.0.0
#r "nuget: ArturRios.Jwt, 1.0.0"
#:package ArturRios.Jwt@1.0.0
#addin nuget:?package=ArturRios.Jwt&version=1.0.0
#tool nuget:?package=ArturRios.Jwt&version=1.0.0
Dotnet JWT
Provides a clean, minimal API for creating, validating and reading JSON Web Tokens (JWT) in .NET.
Requirements
- .NET 10.0 or later
Installation
dotnet add package ArturRios.Jwt
Features
- Create signed JWTs (HMAC-SHA256) from a
JwtConfiguration - Validate a JWT's signature against a secret
- Read the user id from a token's
idclaim - Validate a
JwtConfigurationwith FluentValidation rules before using it
Usage
Configuring
using ArturRios.Jwt;
var configuration = new JwtConfiguration(
expirationInSeconds: 3600,
issuer: "my-api",
audience: "my-app",
secret: "a-secret-key-that-is-at-least-32-bytes-long",
claims: new Dictionary<string, string> { { "id", "42" } }
);
Validating the configuration
var validator = new JwtConfigurationValidator();
var result = validator.Validate(configuration);
if (!result.IsValid)
{
// inspect result.Errors
}
Creating a token
var handler = new JwtHandler();
var token = handler.CreateToken(configuration);
Validating a token
var isValid = await handler.IsTokenValidAsync(token, configuration.Secret);
Reading the user id from a token
var userId = handler.GetUserIdFromToken(token);
Note: tokens are signed with HMAC-SHA256, which requires a secret of at least 32 bytes (256 bits).
Versioning
Semantic Versioning (SemVer). Breaking changes result in a new major version. New methods or non-breaking behavior changes increment the minor version; fixes or tweaks increment the patch.
Build, test and publish
Use the official .NET CLI to build, test and publish the project and Git for source control. If you want, optional helper toolsets I built to facilitate these tasks are available:
Legal Details
This project is licensed under the MIT License. A copy of the license is available at LICENSE in the repository.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- FluentValidation (>= 12.1.1)
- System.IdentityModel.Tokens.Jwt (>= 8.19.1)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on ArturRios.Jwt:
| Package | Downloads |
|---|---|
|
ArturRios.Util.WebApi
Utilities for developing web API's in .NET |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0 | 152 | 7/2/2026 |