NuvTools.Security.Identity.EntityFrameworkCore 10.0.0

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

Nuv Tools Security - ASP.NET Identity Libraries

NuGet License

Nuv Tools Security provides a modular set of libraries designed to simplify and enhance ASP.NET Identity integration for modern .NET applications. These libraries target .NET 8, .NET 9, and .NET 10, offering solutions for identity models, helper utilities, ASP.NET Core integration, and Entity Framework Core support.


📦 Libraries

Nuv Tools Security is organized into four main libraries:

Library Purpose NuGet
NuvTools.Security.Identity.Models Identity models and forms NuGet
NuvTools.Security.Identity Authorization helpers and utilities NuGet
NuvTools.Security.Identity.AspNetCore ASP.NET Core integration NuGet
NuvTools.Security.Identity.EntityFrameworkCore EF Core persistence layer NuGet

Each library is designed for modular use, allowing you to include only the components relevant to your project.


🚀 Features

  • Multi-Framework Support: Targets .NET 8, .NET 9, and .NET 10
  • Localized Validation: Built-in resource-based validation messages for multilingual applications
  • Permission-Based Authorization: Dynamic policy generation for fine-grained access control
  • Password Complexity: Configurable password requirements with custom validation attributes
  • User Management Service: Comprehensive user operations including CRUD, email confirmation, and password management
  • Token Management: Built-in support for JWT and refresh token workflows
  • Result Pattern: Standardized IResult and IResult<T> return types instead of exceptions
  • EF Core Extensions: Batch operations and transaction support for identity persistence
  • Form Models: Ready-to-use DTOs for common identity operations (login, registration, password reset, etc.)

📥 Installation

Install the packages via NuGet Package Manager:

# Install the models library
dotnet add package NuvTools.Security.Identity.Models

# Install the authorization helpers
dotnet add package NuvTools.Security.Identity

# Install ASP.NET Core integration
dotnet add package NuvTools.Security.Identity.AspNetCore

# Install EF Core support
dotnet add package NuvTools.Security.Identity.EntityFrameworkCore

📖 Library Details

1. NuvTools.Security.Identity.Models

Provides base models, form DTOs, and API response models for ASP.NET Identity.

Target Frameworks: .NET 8, .NET 9, .NET 10

Key Components:

  • UserBase<TKey> - Base class for user entities with profile data and validation
  • RoleBase<TKey> - Base class for role entities with claims support
  • Form Models: LoginForm, UserForm, ChangePasswordForm, ForgotPasswordForm, ResetPasswordForm, UpdateProfileForm, UserWithPasswordForm
  • API Models: TokenResponse, RefreshTokenRequest
  • UserRoles - DTO for user-role associations

Usage Example:

using NuvTools.Security.Identity.Models;

// Define your user entity
public class ApplicationUser : UserBase<Guid>
{
    // Add custom properties if needed
}

// Use in registration
public class RegistrationDto : UserWithPasswordForm
{
    // Inherits Email, Name, Surname, Password, ConfirmPassword
    // with validation and password complexity requirements
}

2. NuvTools.Security.Identity

Helper library offering permission-based authorization and policy providers.

Target Frameworks: .NET 8, .NET 9, .NET 10

Key Components:

  • AuthorizationPermissionPolicyProvider - Dynamic policy generation based on permission claims
  • PermissionRequirement - Authorization requirement for permission-based access
  • PermissionAuthorizationHandler - Handles permission claim validation

Usage Example:

using NuvTools.Security.Identity.Policy;
using Microsoft.AspNetCore.Authorization;

// Configure in Program.cs
builder.Services.AddSingleton<IAuthorizationPolicyProvider, AuthorizationPermissionPolicyProvider>();
builder.Services.AddSingleton<IAuthorizationHandler, PermissionAuthorizationHandler>();

// Use in controllers
[Authorize(Policy = "Permission.Users.Create")]
public IActionResult CreateUser()
{
    // Only users with "Permission.Users.Create" claim can access
}

3. NuvTools.Security.Identity.AspNetCore

Server-side library providing user management services and role extensions.

Target Frameworks: .NET 8, .NET 9, .NET 10

Key Components:

  • UserServiceBase<TUser, TRole, TKey> - Comprehensive user management operations
  • RoleManagerExtensions - Extension methods for role and permission management

Available Operations:

  • User CRUD (Create, Read, Update, Delete)
  • Email confirmation and change
  • Password reset and change
  • Role assignment and management
  • User status toggling

Usage Example:

using NuvTools.Security.Identity.AspNetCore.Services;
using NuvTools.Security.Identity.AspNetCore.Extensions;

// Implement your user service
public class UserService : UserServiceBase<ApplicationUser, ApplicationRole, Guid>
{
    public UserService(UserManager<ApplicationUser> userManager)
        : base(userManager) { }
}

// Use in your application
public class AccountController : ControllerBase
{
    private readonly UserService _userService;

    public async Task<IActionResult> Register(UserWithPasswordForm model)
    {
        var user = new ApplicationUser
        {
            Email = model.Email,
            Name = model.Name,
            Surname = model.Surname,
            Password = model.Password
        };

        var result = await _userService.CreateAsync(user);

        if (result.Succeeded)
            return Ok(new { userId = result.Data });

        return BadRequest(result.Errors);
    }
}

// Add permission claims to roles
public async Task ConfigureRoles(RoleManager<ApplicationRole> roleManager)
{
    var adminRole = await roleManager.FindByNameAsync("Admin");

    await roleManager.AddPermissionClaims(adminRole,
        "Permission.Users.Create",
        "Permission.Users.Read",
        "Permission.Users.Update",
        "Permission.Users.Delete"
    );
}

4. NuvTools.Security.Identity.EntityFrameworkCore

Entity Framework Core extensions for identity persistence with advanced operations.

Target Frameworks: .NET 8, .NET 9, .NET 10

Key Components:

  • IdentityDbContextBase<TUser, TRole, TIdentityKey> - Enhanced DbContext for identity
  • Transaction support with execution strategies
  • Batch operations for list synchronization

Usage Example:

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
    }
}

// Use batch operations
public async Task UpdateUserRoles(Guid userId, List<string> newRoles)
{
    var userRoles = newRoles.Select(r => new IdentityUserRole<Guid>
    {
        UserId = userId,
        RoleId = GetRoleId(r)
    }).ToList();

    // Synchronize roles - adds new, removes missing
    await _context.SyncFromListAsync(
        userRoles,
        ur => ur.RoleId,
        ur => ur.UserId == userId
    );

    await _context.SaveChangesAsync();
}

🔑 Key Features Explained

Permission-Based Authorization

The permission system allows dynamic policy creation based on claims:

// Assign permissions to roles
await roleManager.AddPermissionClaim(adminRole, "Permission.Users.Manage");
await roleManager.AddPermissionClaim(editorRole, "Permission.Content.Edit");

// Protect endpoints with permissions
[Authorize(Policy = "Permission.Users.Manage")]
public IActionResult ManageUsers() { }

[Authorize(Policy = "Permission.Content.Edit")]
public IActionResult EditContent() { }

Password Complexity

Passwords are validated with customizable complexity requirements:

// Password requirements are built into UserBase and form models
// - Minimum 6 characters, maximum 40 characters
// - At least 1 uppercase letter
// - At least 1 lowercase letter
// - At least 1 digit

Localized Validation

All validation messages support localization through resource files:

// Messages automatically use the configured culture
[Required(ErrorMessageResourceName = nameof(Messages.XRequired),
         ErrorMessageResourceType = typeof(Messages))]
public string Email { get; set; }

🛠️ Development

Building the Solution

# Build all projects
dotnet build NuvTools.Security.Identity.slnx

# Build in Release mode (generates NuGet packages)
dotnet build NuvTools.Security.Identity.slnx -c Release

# Clean build artifacts
dotnet clean NuvTools.Security.Identity.slnx

Project Structure

nuvtools-security-identity/
├── src/
│   ├── NuvTools.Security.Identity.Models/
│   ├── NuvTools.Security.Identity/
│   ├── NuvTools.Security.Identity.AspNetCore/
│   └── NuvTools.Security.Identity.EntityFrameworkCore/
├── CLAUDE.md                    # Developer guidance for AI assistants
├── README.md                    # This file
└── NuvTools.Security.Identity.slnx

📄 License

This project is licensed under the terms specified in the LICENSE file.



📝 Version

Current Version: 10.0.0

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
10.0.0 204 12/6/2025
9.5.0 175 10/26/2025
9.2.2 776 5/24/2025
9.2.1 182 5/23/2025
9.2.0 225 4/13/2025
9.1.1 171 4/12/2025
9.1.0 219 4/10/2025