ImanSoftware.Jwt
1.0.0
dotnet add package ImanSoftware.Jwt --version 1.0.0
NuGet\Install-Package ImanSoftware.Jwt -Version 1.0.0
<PackageReference Include="ImanSoftware.Jwt" Version="1.0.0" />
<PackageVersion Include="ImanSoftware.Jwt" Version="1.0.0" />
<PackageReference Include="ImanSoftware.Jwt" />
paket add ImanSoftware.Jwt --version 1.0.0
#r "nuget: ImanSoftware.Jwt, 1.0.0"
#:package ImanSoftware.Jwt@1.0.0
#addin nuget:?package=ImanSoftware.Jwt&version=1.0.0
#tool nuget:?package=ImanSoftware.Jwt&version=1.0.0
ImanSoftware.Jwt
Version: 1.0.0 | Last Updated: August 2026
A lightweight and extensible JWT authentication library for .NET with token generation, validation, and ASP.NET Core middleware support.
ImanSoftware.Jwt provides a clean abstraction over JWT operations, making it easy to generate, validate, and process JSON Web Tokens while integrating seamlessly with ASP.NET Core applications.
Installation
Install the package using the .NET CLI:
dotnet add package ImanSoftware.Jwt
Why ImanSoftware.Jwt?
Working directly with the JWT APIs often leads to duplicated configuration and authentication logic across projects.
Instead of scattering JWT-related code throughout your application, this package centralizes token generation, validation, and authentication into a single, reusable service.
Benefits include:
- Simplified JWT management
- Dependency Injection friendly
- Clean Architecture compatible
- Easy integration with ASP.NET Core
- Lightweight and testable
Features
- ✅
IJwtTokenServiceabstraction - ✅ JWT generation
- ✅ JWT validation
- ✅ Read claims from expired tokens
- ✅ Configurable
JwtOptions - ✅ ASP.NET Core authentication middleware
- ✅ Dependency Injection support
- ✅ Easy application setup
IJwtTokenService
The primary abstraction for working with JWT tokens.
Available methods:
GenerateToken()ValidateToken()GetPrincipalFromExpiredToken()
Example:
string token = _jwt.GenerateToken(claims);
bool isValid = _jwt.ValidateToken(token);
var principal = _jwt.GetPrincipalFromExpiredToken(token);
JwtTokenService
The default implementation is built on top of System.IdentityModel.Tokens.Jwt.
Features include:
- Secure JWT generation
- Token validation
- Claims extraction
- Expired token support (useful for refresh token scenarios)
- Standards-compliant implementation
JwtOptions
JWT behavior is configured through the JwtOptions class.
Available settings:
| Property | Description |
|---|---|
SecretKey |
Secret key used to sign tokens |
Issuer |
Token issuer |
Audience |
Token audience |
ExpiryMinutes |
Token expiration time |
ValidateLifetime |
Enables or disables lifetime validation |
Example configuration:
{
"Jwt": {
"SecretKey": "your-secret-key",
"Issuer": "MyApplication",
"Audience": "MyApplication",
"ExpiryMinutes": 60,
"ValidateLifetime": true
}
}
Dependency Injection
Register the JWT service using your application configuration.
var jwtOptions = builder.Configuration
.GetSection("Jwt")
.Get<JwtOptions>();
services.AddJwtTokenService(jwtOptions);
After registration, IJwtTokenService can be injected anywhere in your application.
JWT Middleware
The package includes a dedicated middleware that:
- Reads the JWT from the
Authorizationheader - Validates the token
- Creates the authenticated
ClaimsPrincipal - Assigns the user to
HttpContext.User
Register the middleware in your request pipeline:
app.UseJwtAuthentication();
Example
using ImanSoftware.Jwt;
public class AuthService
{
private readonly IJwtTokenService _jwt;
public AuthService(IJwtTokenService jwt)
{
_jwt = jwt;
}
public string Login(string username, string password)
{
// Validate user credentials...
var claims = new[]
{
new Claim(
ClaimTypes.NameIdentifier,
userId.ToString())
};
return _jwt.GenerateToken(claims);
}
}
Complete Setup
var jwtOptions = builder.Configuration
.GetSection("Jwt")
.Get<JwtOptions>();
services.AddJwtTokenService(jwtOptions);
var app = builder.Build();
app.UseJwtAuthentication();
Common Use Cases
- User authentication
- API authorization
- Refresh token workflows
- Claims-based identity
- Microservices authentication
- Stateless security
Design Goals
- Secure by default
- Clean abstraction
- Dependency Injection friendly
- Lightweight
- Easy configuration
- ASP.NET Core integration
- Standards compliant
- Clean Architecture compatible
- Easy to test
Requirements
- .NET Standard 2.0+
- .NET 6+
- .NET 7+
- .NET 8+
- .NET 9+
- .NET 10.0+
Author
Iman Estiri
📧 contact.imanestiri@gmail.com
📧 dev.imanestiri@gmail.com
GitHub:
License
This project is licensed under the MIT License.
| 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
- Microsoft.AspNetCore.Http (>= 2.3.11)
- Microsoft.IdentityModel.Tokens (>= 8.21.0)
- System.IdentityModel.Tokens.Jwt (>= 8.21.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on ImanSoftware.Jwt:
| Package | Downloads |
|---|---|
|
ImanSoftware.Framework
Umbrella package that bundles all ImanSoftware modules for a unified development experience. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0 | 159 | 8/3/2026 |