NetDevPack.Identity 9.0.1

dotnet add package NetDevPack.Identity --version 9.0.1
                    
NuGet\Install-Package NetDevPack.Identity -Version 9.0.1
                    
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="NetDevPack.Identity" Version="9.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="NetDevPack.Identity" Version="9.0.1" />
                    
Directory.Packages.props
<PackageReference Include="NetDevPack.Identity" />
                    
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 NetDevPack.Identity --version 9.0.1
                    
#r "nuget: NetDevPack.Identity, 9.0.1"
                    
#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 NetDevPack.Identity@9.0.1
                    
#: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=NetDevPack.Identity&version=9.0.1
                    
Install as a Cake Addin
#tool nuget:?package=NetDevPack.Identity&version=9.0.1
                    
Install as a Cake Tool

<img src="https://repository-images.githubusercontent.com/268701472/8bf84980-a6ce-11ea-83da-e2133c5a3a7a" alt=".NET DevPack" width="300px" />

What is the .NET DevPack.Identity?

.NET DevPack Identity is a set of common implementations to help you implementing ASP.NET Identity, JWT, claims validation and another facilities

Codacy Badge Build status .NET Core License

Give a Star! ⭐

If you liked the project or if NetDevPack helped you, please give a star 😉

Get Started

Package Version Popularity
NetDevPack.Identity NuGet Nuget

.NET DevPack.Identity can be installed in your ASP.NET Core application using the Nuget package manager or the dotnet CLI.

dotnet add package NetDevPack.Identity

Compatibility

Version Target frameworks NetDevPack.Security.Jwt
9.x .NET 10 (LTS) 11.x (from 9.0.1)
8.x .NET 8, .NET 10 8.x

Breaking change in v9: .NET 8 is out of support since 2026-11-10 and is no longer targeted. If you need it, stay on 8.x. The public API did not change.

If you want to use our IdentityDbContext (ASP.NET Identity standard) you will need to create the Identity tables. Set your connection string in the appsettings.json and follow the next steps:

Add the IdentityDbContext configuration in your startup.cs:

services.AddIdentityEntityFrameworkContextConfiguration(options => 
	options.UseSqlServer(configuration.GetConnectionString("DefaultConnection"), 
	b=>b.MigrationsAssembly("AspNetCore.Jwt.Sample")));

Note: You must inform the namespace to avoid migration errors

Note: You must install the Microsoft.EntityFrameworkCore.SqlServer or another provider like Npgsql.EntityFrameworkCore.PostgreSQL package to have support from your database. Find the package for your database here

Add the Identity configuration in ConfigureServices method of your startup.cs:

services.AddIdentityConfiguration();

Note: This extension returns an IdentityBuilder to allow you extending the configuration

Add the Identity configuration in Configure method of your startup.cs:

app.UseAuthConfiguration();

Note: This method need to be set between app.UseRouting() and app.UseEndpoints()

Run the command to generate the migration files:

dotnet ef migrations add Initial --context NetDevPackAppDbContext --project <Your patch>/<Your Project>.csproj

Run the command to generate the database:

dotnet ef database update --context NetDevPackAppDbContext --project <Your patch>/<Your Project>.csproj

Note: If are you using your own IdentityDbContext you must change the NetDevPackAppDbContext value to your context class name in the commands above.

After execute this steps you will be all set to use the Identity in your Application.

Configuring JWT

If you want to generate JSON Web Tokens in your application you need to add the JWT configuration in ConfigureServices method of your startup.cs

services.AddJwtConfiguration(Configuration)
        .AddNetDevPackIdentity<IdentityUser>();

Set your appsettings.json file with this values:

"AppJwtSettings": {
    "Audience": "MyApplication.Name"
}

It's possible to configure some aspects of token

Key Meaning Default
Expiration Expiration time (in hours) 1
Issuer The party that "created" the token and signed it with its private key. Usually the application Url Get current root Url from HttpContext
Audience API's that should accept the token. E.g your application Main name. NetDevPack
RefreshTokenExpiration Refresh token expiration (In Days) 30
RefreshTokenType OneTime or ReUse 30
SecretKey Deprecated Is your key to build JWT. Read notes Do not use it

Note: Now we are using NetDevPack.Security.Jwt to generate and Store your keys. It generate a RSA 2048 by default. You can check the project for more info.

Generating JWT

You will need to set a single dependency in your Authentication Controller:

public AuthController(IJwtBuilder jwtBuilder)
{
    _jwtBuilder = jwtBuilder;
}

After user register or login process you can generate a JWT to respond the request. Use our implementation, you just need inform the user email and the dependencies injected in your controller:

return _jwtBuilder
	.WithEmail(email)
    	.WithRefreshToken()
	.BuildToken();

Note: This builder can return a single string with JWT or a complex object UserResponse if you want return more data than a single JWT string.

Adding Claims to your JWT

You can call more methods in JwtBuilder to provide more information about the user:

return _jwtBuilder
    .WithEmail(email)
    .WithJwtClaims()
    .WithUserClaims()
    .WithUserRoles()
    .WithRefreshToken()
    .BuildToken();
Method Meaning
WithJwtClaims() Claims of JWT like sub, jti, nbf and others
WithUserClaims() The user claims registered in AspNetUserClaims table
WithUserRoles() The user roles (as claims) registered in AspNetUserRoles table
BuildToken() Build and return the JWT as single string

If you want return your complex object UserResponse you need to change the last method to:

return _jwtBuilder
    .WithEmail(email)
    .WithJwtClaims()
    .WithUserClaims()
    .WithUserRoles()
    .WithRefreshToken()
    .BuildUserResponse();

Examples

Use the sample application to understand how NetDevPack.Identity can be implemented and help you to decrease the complexity of your application and development time.

Compatibility

The NetDevPack.Identity was developed to be implemented in ASP.NET Core. It support all .NET versions since 3.1.

About

.NET DevPack.Identity was developed by Eduardo Pires under the MIT license.

Product 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. 
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 NetDevPack.Identity:

Package Downloads
ArkCommon

.NET DevPack is a set of common implementations to help you implementing DDD, CQRS, Specification Patterns and another facilities

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on NetDevPack.Identity:

Repository Stars
desenvolvedor-io/dev-store
A microservices e-commerce reference application built with ASP.NET 9
Version Downloads Last Updated
9.0.1 54 11/18/2026
9.0.0 50 11/18/2026
8.0.1 49 11/18/2026
8.0.0 1,825 2/5/2026
7.0.1 32,360 11/17/2022
7.0.0 1,097 11/17/2022
6.1.7 10,483 4/18/2022
6.0.5 45,377 12/14/2021
6.0.1 1,818 2/27/2022
5.0.1 7,427 5/21/2021
2.0.0 1,193 2/27/2022
Loading failed