NuvTools.Security.Identity
10.1.0
dotnet add package NuvTools.Security.Identity --version 10.1.0
NuGet\Install-Package NuvTools.Security.Identity -Version 10.1.0
<PackageReference Include="NuvTools.Security.Identity" Version="10.1.0" />
<PackageVersion Include="NuvTools.Security.Identity" Version="10.1.0" />
<PackageReference Include="NuvTools.Security.Identity" />
paket add NuvTools.Security.Identity --version 10.1.0
#r "nuget: NuvTools.Security.Identity, 10.1.0"
#:package NuvTools.Security.Identity@10.1.0
#addin nuget:?package=NuvTools.Security.Identity&version=10.1.0
#tool nuget:?package=NuvTools.Security.Identity&version=10.1.0
NuvTools.Security.Identity
A modular library suite for ASP.NET Identity integration targeting .NET 8, .NET 9, and .NET 10. Provides identity models, permission-based authorization, user management services, and Entity Framework Core persistence.
Libraries
Installation
dotnet add package NuvTools.Security.Identity.Models
dotnet add package NuvTools.Security.Identity
dotnet add package NuvTools.Security.Identity.AspNetCore
dotnet add package NuvTools.Security.Identity.EntityFrameworkCore
NuvTools.Security.Identity.Models
Base models, form DTOs, and API response models for ASP.NET Identity.
Key Components:
UserBase<TKey>-- Abstract user entity extendingIdentityUser<TKey>with Email, Name, Surname, Status, and password validation (6-40 chars, min 1 uppercase, 1 lowercase, 1 digit)RoleBase<TKey>-- Abstract role entity extendingIdentityRole<TKey>with Name and Claims- Form models:
LoginForm,UserForm,UserWithPasswordForm,ChangePasswordForm,ForgotPasswordForm,ResetPasswordForm,UpdateProfileForm - API models:
TokenResponse,RefreshTokenRequest UserRoles-- DTO for user-role associations
Usage:
using NuvTools.Security.Identity.Models;
public class ApplicationUser : UserBase<Guid>
{
// Add custom properties if needed
}
public class RegistrationDto : UserWithPasswordForm
{
// Inherits Email, Name, Surname, Password, ConfirmPassword
// with localized validation and password complexity requirements
}
NuvTools.Security.Identity
Permission-based authorization with dynamic policy provider and claim-based permission handler.
Key Components:
AuthorizationPermissionPolicyProvider-- Dynamically generates policies for names starting with "Permission."PermissionRequirement-- Authorization requirement carrying a permission stringPermissionAuthorizationHandler-- Validates permission claims with issuer "LOCAL AUTHORITY"
Usage:
using NuvTools.Security.Identity.Policy;
// Configure in Program.cs
builder.Services.AddSingleton<IAuthorizationPolicyProvider, AuthorizationPermissionPolicyProvider>();
builder.Services.AddSingleton<IAuthorizationHandler, PermissionAuthorizationHandler>();
// Protect endpoints with permissions
[Authorize(Policy = "Permission.Users.Create")]
public IActionResult CreateUser() { }
NuvTools.Security.Identity.AspNetCore
Server-side user management service and role administration. All methods return IResult / IResult<T> from the ResultWrapper pattern.
Key Components:
UserServiceBase<TUser, TRole, TKey>-- Abstract service with user CRUD, email confirmation/change, password management, and role operationsRoleManagerExtensions-- Extension methods for adding claims and permission claims to roles
Available Operations:
- User CRUD:
GetAllAsync,GetAsync,GetByEmailAsync,CreateAsync,UpdateAsync,DeleteAsync - User with roles:
CreateWithRolesAsync,GetRolesAsync,UpdateRolesAsync - Email:
GenerateEmailConfirmationTokenAsync,GenerateEmailConfirmationUriAsync,ConfirmEmailAsync,RequestChangeEmailUrlAsync,ChangeEmailAsync - Password:
ChangePasswordAsync,RequestResetPasswordUrlAsync,ResetPasswordAsync - Status:
ToggleUserStatusAsync
Usage:
using NuvTools.Security.Identity.AspNetCore.Services;
using NuvTools.Security.Identity.AspNetCore.Extensions;
public class UserService : UserServiceBase<ApplicationUser, ApplicationRole, Guid>
{
public UserService(UserManager<ApplicationUser> userManager)
: base(userManager) { }
}
// Add permission claims to roles
await roleManager.AddPermissionClaims(adminRole,
"Permission.Users.Create",
"Permission.Users.Read",
"Permission.Users.Update",
"Permission.Users.Delete"
);
NuvTools.Security.Identity.EntityFrameworkCore
Entity Framework Core persistence layer with transaction management and batch operations.
Key Components:
IdentityDbContextBase<TUser, TRole, TIdentityKey>-- Abstract DbContext extendingIdentityDbContext, implementingIDbContextCommandsandIDbContextWithListCommands- Transaction management:
BeginTransactionAsync,CommitTransactionAsync,RollbackTransactionAsync - Execution strategy:
ExecuteWithStrategyAsync - CRUD:
AddAndSaveAsync,UpdateAndSaveAsync,RemoveAndSaveAsync - Batch operations:
SyncFromListAsync,AddOrUpdateFromListAsync,AddOrRemoveFromListAsync
Usage:
using NuvTools.Security.Identity.EntityFrameworkCore;
public class ApplicationDbContext : IdentityDbContextBase<ApplicationUser, ApplicationRole, Guid>
{
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options)
: base(options) { }
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
// Configure your entities
}
}
Building
This solution uses the .slnx (XML-based solution) format.
dotnet build NuvTools.Security.Identity.slnx
dotnet build NuvTools.Security.Identity.slnx -c Release
Project Structure
nuvtools-security-identity/
├── src/
│ ├── NuvTools.Security.Identity.Models/
│ ├── NuvTools.Security.Identity/
│ ├── NuvTools.Security.Identity.AspNetCore/
│ └── NuvTools.Security.Identity.EntityFrameworkCore/
├── NuvTools.Security.Identity.slnx
└── README.md
License
This project is licensed under the terms specified in the LICENSE file.
Links
| 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 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.Authorization (>= 10.0.2 && < 10.1.0)
- NuvTools.Security (>= 10.1.0 && < 10.2.0)
-
net8.0
- Microsoft.AspNetCore.Authorization (>= 10.0.2 && < 10.1.0)
- NuvTools.Security (>= 10.1.0 && < 10.2.0)
-
net9.0
- Microsoft.AspNetCore.Authorization (>= 10.0.2 && < 10.1.0)
- NuvTools.Security (>= 10.1.0 && < 10.2.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.