AuthPlus.Identity
1.0.16
dotnet add package AuthPlus.Identity --version 1.0.16
NuGet\Install-Package AuthPlus.Identity -Version 1.0.16
<PackageReference Include="AuthPlus.Identity" Version="1.0.16" />
<PackageVersion Include="AuthPlus.Identity" Version="1.0.16" />
<PackageReference Include="AuthPlus.Identity" />
paket add AuthPlus.Identity --version 1.0.16
#r "nuget: AuthPlus.Identity, 1.0.16"
#:package AuthPlus.Identity@1.0.16
#addin nuget:?package=AuthPlus.Identity&version=1.0.16
#tool nuget:?package=AuthPlus.Identity&version=1.0.16
AuthPlus.Identity
AuthPlus.Identity is a .NET 8+ class library designed to simplify user authentication and authorization in your ASP.NET Core applications. It provides ready-to-use APIs for users, roles, JWT authentication, email confirmation, password reset, and external login providers.
Features
- User Registration and Login
- Password Reset and Email Confirmation
- User Management (CRUD)
- Role Management (CRUD, assign/remove roles)
- JWT-Based Authentication
- Configurable Email Service
- External Authentication Providers (Google, Facebook, LinkedIn, etc.)
- Extendable Validators and Policies
- Ready-to-use Controllers and Endpoints
- Supports SQL Server, PostgreSQL (via EF Core)
Getting Started
Prerequisites
- .NET 8 SDK or later
- NuGet Package Manager
Installation
Add the package to your project:
dotnet add package AuthPlus.Identity
Configuration
Add the following settings to your appsettings.json:
{
"JwtSettings": {
"SecretKey": "your-32-character-super-secret-key-here", // Min 32 chars
"Issuer": "your-app-name",
"Audience": "your-app-clients",
"ExpirationMinutes": 60
},
"EmailSettings": {
"SmtpServer": "smtp.example.com",
"SmtpPort": 587,
"SmtpUser": "your-email@example.com",
"SmtpPassword": "your-email-password",
"BaseUrl": "https://your-app-url"
},
"ConnectionStrings": {
"DefaultConnection": "Server=.;Database=AuthDb;Trusted_Connection=True;"
}
}
Optional: Add external login providers by implementing
IExternalAuthProvider(e.g., Google, Facebook, LinkedIn).
Setup in Program.cs
var builder = WebApplication.CreateBuilder(args);
// Add AuthPlus Identity (select your database provider)
builder.Services.AddAuthPlusIdentity(builder.Configuration, options =>
{
options.UseSqlServer(builder.Configuration.GetConnectionString("DefaultConnection"));
// options.UsePostgres(...);
// options.UseMySql(...);
});
// Register external authentication providers (optional)
builder.Services.AddHttpClient<GoogleAuthProvider>();
builder.Services.AddHttpClient<MicrosoftAuthProvider>();
builder.Services.AddScoped<IExternalAuthProvider, GoogleAuthProvider>();
builder.Services.AddScoped<IExternalAuthProvider, MicrosoftAuthProvider>();
// Add controllers
builder.Services.AddControllers();
var app = builder.Build();
// IMPORTANT: Middleware must be in correct order
app.UseRouting(); // This must come first!
app.UseAuthentication();
app.UseAuthorization();
app.MapControllers();
app.Run();
AddAuthPlusIdentityautomatically registers:
- Identity services
- JWT authentication
- Email service
- IUserService, IRoleService, IAuthService
- Policies (
RequireAdminRole,RequireUserRole,RequireAdminOrUserRole)- Validators for DTOs (
LoginDto,RegisterDto,UserDto,ResetPasswordDto)
Controllers & Endpoints
AuthController
| Endpoint | Method | Description |
|---|---|---|
/api/auth/register |
POST | Register a new user |
/api/auth/login |
POST | Login a user |
/api/auth/external-login |
POST | Login via external provider (Google, Facebook, etc.) |
/api/auth/refresh-token |
POST | Refresh JWT token |
/api/auth/forgot-password |
POST | Send password reset email |
/api/auth/reset-password |
POST | Reset user password |
UserController
| Endpoint | Method | Authorization | Description |
|---|---|---|---|
/api/user |
GET | Admin | Get all users |
/api/user/{id} |
GET | User/Admin | Get user by ID |
/api/user |
POST | Admin | Create a user |
/api/user/{id} |
PUT | User/Admin | Update user info |
/api/user/{id} |
DELETE | Admin | Delete a user |
/api/user/{userId}/roles/{roleName} |
POST | Admin | Assign role to user |
/api/user/{userId}/roles/{roleName} |
DELETE | Admin | Remove role from user |
/api/user/confirm-email?token=&userId= |
GET | Anonymous | Confirm user email |
RoleController
| Endpoint | Method | Authorization | Description |
|---|---|---|---|
/api/role/all |
GET | Admin | Get all roles |
/api/role/{id} |
GET | Admin | Get role by ID |
/api/role |
POST | Admin | Create a new role |
/api/role/{id} |
PUT | Admin | Update role |
/api/role/{id} |
DELETE | Admin | Delete role |
Extending
You can extend and customize the library:
- Roles & Policies: Extend
AuthorizationPoliciesor add custom roles. - Validators: Override or create custom DTO validators.
- ApplicationUser: Add new properties to your user class.
- Email Service: Implement
IEmailServicefor custom email logic. - External Providers: Implement
IExternalAuthProviderfor social logins.
Optional: Override Default Validators
public class CustomRegisterDtoValidator : RegisterDtoValidator
{
public CustomRegisterDtoValidator()
{
RuleFor(x => x.Password)
.Must(p => p.Contains("@"))
.WithMessage("Password must contain '@'.");
RuleFor(x => x.Password)
.Matches(@"\d")
.WithMessage("Password must contain at least one number.");
}
}
// Register in Program.cs to replace default validator
builder.Services.AddTransient<IBaseValidator<RegisterDto>, CustomRegisterDtoValidator>();
Example: Register User in Controller
[HttpPost("register")]
public async Task<IActionResult> Register([FromBody] RegisterDto registerDto)
{
var result = await _authService.RegisterAsync(registerDto);
return !result.Succeeded ? BadRequest(result.Errors) : Ok(result);
}
License & Support
- MIT License
- For questions or support: muhdinmussema@gmail.com
| 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
- FluentValidation (>= 11.11.0)
- Microsoft.AspNetCore.Authentication.JwtBearer (>= 10.0.0)
- Microsoft.AspNetCore.Identity.EntityFrameworkCore (>= 10.0.0)
- Microsoft.EntityFrameworkCore (>= 10.0.0)
- Microsoft.EntityFrameworkCore.SqlServer (>= 10.0.0)
- Newtonsoft.Json (>= 13.0.4)
- Npgsql.EntityFrameworkCore.PostgreSQL (>= 10.0.0)
-
net8.0
- FluentValidation (>= 11.11.0)
- Microsoft.AspNetCore.Authentication.JwtBearer (>= 8.0.4)
- Microsoft.AspNetCore.Identity.EntityFrameworkCore (>= 8.0.4)
- Microsoft.EntityFrameworkCore (>= 8.0.4)
- Microsoft.EntityFrameworkCore.SqlServer (>= 8.0.4)
- Newtonsoft.Json (>= 13.0.4)
- Npgsql.EntityFrameworkCore.PostgreSQL (>= 8.0.4)
-
net9.0
- FluentValidation (>= 11.11.0)
- Microsoft.AspNetCore.Authentication.JwtBearer (>= 9.0.0)
- Microsoft.AspNetCore.Identity.EntityFrameworkCore (>= 9.0.0)
- Microsoft.EntityFrameworkCore (>= 9.0.0)
- Microsoft.EntityFrameworkCore.SqlServer (>= 9.0.0)
- Newtonsoft.Json (>= 13.0.4)
- Npgsql.EntityFrameworkCore.PostgreSQL (>= 9.0.0)
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 |
|---|---|---|
| 1.0.16 | 118 | 1/15/2026 |
| 1.0.15 | 112 | 1/15/2026 |
| 1.0.14 | 110 | 1/14/2026 |
| 1.0.13 | 115 | 1/14/2026 |
| 1.0.12 | 113 | 1/14/2026 |
| 1.0.11 | 114 | 1/14/2026 |
| 1.0.10 | 229 | 9/15/2024 |
| 1.0.9 | 183 | 9/5/2024 |
| 1.0.8 | 170 | 9/4/2024 |
| 1.0.7 | 161 | 9/4/2024 |
| 1.0.6 | 165 | 9/4/2024 |
| 1.0.4 | 161 | 9/2/2024 |
| 1.0.3 | 171 | 9/2/2024 |
| 1.0.2 | 163 | 9/2/2024 |
| 1.0.1 | 172 | 9/1/2024 |
| 1.0.0 | 178 | 9/1/2024 |