Capelladev.IdentityService
0.2.1
dotnet add package Capelladev.IdentityService --version 0.2.1
NuGet\Install-Package Capelladev.IdentityService -Version 0.2.1
<PackageReference Include="Capelladev.IdentityService" Version="0.2.1" />
<PackageVersion Include="Capelladev.IdentityService" Version="0.2.1" />
<PackageReference Include="Capelladev.IdentityService" />
paket add Capelladev.IdentityService --version 0.2.1
#r "nuget: Capelladev.IdentityService, 0.2.1"
#:package Capelladev.IdentityService@0.2.1
#addin nuget:?package=Capelladev.IdentityService&version=0.2.1
#tool nuget:?package=Capelladev.IdentityService&version=0.2.1
IdentityService
An Token Based Authentication Library integrated into ASP.NET Core Identity. Currently supports JWT with IdentityService.Jwt.
This project is still under development and breaking changes occur frequently. It may be not working well that certain features or APIs on future releases.
Disclaimer
This software is distributed on as an open source software under the MIT License. See the LICENSE file for details.
You can use this software for free, but please be aware that it comes with no warranty or support.
Features
- ASP.NET Core Identity Integration: You can use Identity's built-in user management systems with JWT authentication!
- JWT Token Creation (With various algorithms)
- Refresh Token with rotation
- Token Revocation
Getting Started
IdentityService supports .NET 8.0 and 9.0 as of September 2025. Please follow the steps below to configure the library.
Requirements
- .NET 8.0 or 9.0 SDK
- EF Core
- Database supported by EF Core. (It is recommended to use PostgreSQL)
Microsoft.IdentityModel.TokensMicrosoft.Extensions.Identity.CoreMicrosoft.AspNetCore.Identity.EntityFrameworkCore
Installation
You can install IdentityService from NuGet Gallery by nuget CLI or dotnet CLI.
Remember that you need to install Jwt package to make use of JWT authentication.
dotnet add package Capelladev.IdentityService --version 0.1.0
dotnet add package Capelladev.IdentityService.Jwt --version 0.1.0
appsettings.json Configuration
Add a configuration section for JWT settings in your project's appsettings.json file:
{
"JwtSettings": {
"AccessToken": {
"ValidateIssuer": true,
"ValidateIssuerSigningKey": true,
"Issuers": [
"https://localhost:22000"
],
"ValidateAudience": true,
"Audiences": [
"https://localhost:22000",
"http://localhost:10586"
],
"SecretKey": "your-secret-key",
"SigningAlgorithm": "HS256",
"ExpiresInMinutes": 20
},
"RefreshToken": {
"EnableRefreshToken": true,
"ExpiresInMinutes": 10080
}
}
}
DbContext and Repository Setup
This library is integrated to ASP.NET Core Identity, So it is strongly recommended to use IdentityDbContext.
You need to add DbSet for the refresh token entity to your DbContext class. Remember that please specify the user and key type.
For example:
public DbSet<JwtRefreshTokenEntity<IdentityUser<string>, string>> RefreshTokens { get; set; }
You can use your custom user class based on IdentityUser as well.
Identity Setup
Only 3 methods are required to set up JWT authentication.
- Register
JwtSettingsconfiguration to the DI container.
builder.Services.Configure<JwtSettings>(builder.Configuration.GetSection("JwtSettings"));
- Add
ITokenRepositoryimplementation to the DI container. For instance, If you want to register JWT token, RegisterJwtTokenRepositorywith your user class and DbContext as a scoped service
builder.Services.AddScoped<ITokenRepository, JwtTokenRepository<IdentityUser<string>, string>>(sp =>
new JwtTokenRepository<IdentityUser<string>, string>(sp.GetRequiredService<AppDbContext>()));
- Add an extension method for each token systems. For JWT, call
AddJwtTokenIdentity.
builder.Services.AddJwtTokenIdentity<IdentityUser<string>, string>(builder.Configuration);
As of v0.1.0, IdentityService has extension methods including not only JWT configuration but also default configurations for ASP.NET Core Identity.
Instead of AddIdentity or AddDefaultIdentity, Just invoke AddJwtTokenIdentity. Even setupActions parameter works!
For JWT:
builder.Services.AddJwtTokenIdentity<IdentityUser<string>, IdentityRole, string>(options =>
{
options.User.RequireUniqueEmail = true;
options.Password.RequireDigit = true;
options.Password.RequireLowercase = true;
options.Password.RequireUppercase = true;
options.Password.RequiredLength = 15;
options.Password.RequireNonAlphanumeric = false;
})
.AddEntityFrameworkStores<AppDbContext>()
.AddDefaultTokenProviders();
For the customized ASP.NET Core Identity configuration, you can utilize Add[TokenSystem]Token method along with customized code.
For JWT, Add AddJwtToken.
- Done. Don't forget to inject token service you want to use! There's a sample project with the configuration in samples directory.
Feedback
Feel free to open issues or submit pull requests on GitHub. I welcome any issues or contributions for the better software.
Copyright © 2025 Capella87. Distributed under the MIT License.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. 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. |
-
net8.0
- FluentResults (>= 4.0.0)
- Microsoft.AspNetCore.Identity.EntityFrameworkCore (>= 8.0.20)
- Microsoft.EntityFrameworkCore (>= 8.0.20)
- Microsoft.Extensions.Configuration (>= 8.0.0)
- Microsoft.Extensions.Identity.Core (>= 8.0.20)
- Microsoft.Extensions.Identity.Stores (>= 8.0.20)
- Microsoft.IdentityModel.Tokens (>= 8.14.0)
- System.Text.Json (>= 8.0.6)
-
net9.0
- FluentResults (>= 4.0.0)
- Microsoft.AspNetCore.Identity.EntityFrameworkCore (>= 9.0.9)
- Microsoft.EntityFrameworkCore (>= 9.0.9)
- Microsoft.Extensions.Configuration (>= 9.0.9)
- Microsoft.Extensions.Identity.Core (>= 9.0.9)
- Microsoft.Extensions.Identity.Stores (>= 9.0.9)
- Microsoft.IdentityModel.Tokens (>= 8.14.0)
- System.Text.Json (>= 9.0.9)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Capelladev.IdentityService:
| Package | Downloads |
|---|---|
|
Capelladev.IdentityService.Jwt
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.2.1 | 177 | 9/27/2025 |
| 0.2.0 | 296 | 9/15/2025 |
| 0.1.0-alpha.2 | 138 | 9/12/2025 |