AugusteVN.Modules.Auth.Api 1.0.3

There is a newer version of this package available.
See the version list below for details.
dotnet add package AugusteVN.Modules.Auth.Api --version 1.0.3
                    
NuGet\Install-Package AugusteVN.Modules.Auth.Api -Version 1.0.3
                    
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="AugusteVN.Modules.Auth.Api" Version="1.0.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="AugusteVN.Modules.Auth.Api" Version="1.0.3" />
                    
Directory.Packages.props
<PackageReference Include="AugusteVN.Modules.Auth.Api" />
                    
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 AugusteVN.Modules.Auth.Api --version 1.0.3
                    
#r "nuget: AugusteVN.Modules.Auth.Api, 1.0.3"
                    
#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 AugusteVN.Modules.Auth.Api@1.0.3
                    
#: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=AugusteVN.Modules.Auth.Api&version=1.0.3
                    
Install as a Cake Addin
#tool nuget:?package=AugusteVN.Modules.Auth.Api&version=1.0.3
                    
Install as a Cake Tool

AugusteVN.Modules.Auth.Api

Minimal API endpoints for authentication, identity, roles, and user management — with custom scoped-permission authorization and multi-provider support (EF Core or MongoDB).

Extension Methods

AddAuthApi(this IServiceCollection, IConfiguration, DbProvider)

Registers the full auth pipeline for the chosen database provider:

  • ASP.NET Core Identity with User and Role entities
  • FluentValidation validators from the _Shared assembly
  • SMTP configuration (SmtpConfig) and IdentityConfig (frontend URLs for email links)
  • IEmailSender<TUser> as IdentityEmailSender<TUser> backed by SmtpMailer
  • PermissionAuthorizationHandler and FlexibleAuthorizationPolicyProvider for claims-based scoped authorization
  • Provider-specific UserClaimsPrincipalFactory that emits per-scope permission claims
DbProvider Enum
Value Description
EfCore Uses Entity Framework Core with SQL Server. Requires AddAuthDbContextEfCore() to be called first.
Mongo Uses MongoDB via AspNetCore.Identity.Mongo. Requires AddAuthDbContextMongo() to be called first.
Provider-Specific Registration

EF Core:

builder.Services.AddAuthDbContextEfCore(builder.Configuration);
builder.Services.AddAuthApi(builder.Configuration, DbProvider.EfCore);

MongoDB:

builder.Services.AddAuthDbContextMongo(builder.Configuration);
builder.Services.AddAuthApi(builder.Configuration, DbProvider.Mongo);

Both providers register:

  • EfCoreUserClaimsPrincipalFactory or MongoUserClaimsPrincipalFactory — enriches ClaimsPrincipal with permissions_{Scope} claims
  • IdentityEmailSender<TUser> — generic email sender for confirmation and password-reset links

MapAuthEndpoints(this IEndpointRouteBuilder)

Maps all identity, roles, and users endpoint groups with EndpointExceptionFilter:

  • Identity endpoints under /Auth
  • Roles endpoints under /Roles
  • Users endpoints under /Users

API Routes

Identity

Method Route Authorization Description
POST /Auth/register Anonymous Register a new user account
POST /Auth/login Anonymous Authenticate and receive access/refresh tokens
POST /Auth/forgotPassword Anonymous Request a password reset code via email
POST /Auth/resetPassword Anonymous Reset password using the emailed code
GET /Auth/confirmEmail Anonymous Confirm email address with verification code
POST /Auth/resendConfirmationEmail Anonymous Resend email confirmation link
POST /Auth/refresh Anonymous Exchange refresh token for new access token
GET /Auth/user-info Authorized Get current user profile, roles, and scoped permissions
POST /Auth/user-info Authorized Update current user's password (not yet implemented)
PUT /Auth/user-info Authorized Update current user's profile information

Roles

Method Route Authorization Description
GET /Roles/ ManageRoles Retrieve all roles
GET /Roles/{UserId} ManageRoles Retrieve roles assigned to a specific user
POST /Roles/ ManageRoles Create a new role
PUT /Roles/{Id} ManageRoles Update an existing role
DELETE /Roles/{Id} ManageRoles Delete a role
PUT /Roles/{Id}/permissions ManagePermissions Replace permissions for a specific role

Users

Method Route Authorization Description
GET /Users/ ManageUsers Retrieve a paginated list of users
POST /Users/ ManageUsers Create a new user (not yet implemented)
PUT /Users/ ManageUsers Create or update a user (upsert)
DELETE /Users/{Id} ManageUsers Delete a user

Authorization

The module uses a custom authorization pipeline instead of standard [Authorize] attributes on handlers:

  • AuthorizeAttribute — Converts (scope, sum) pairs into policy names via PolicyNameHelper
  • FlexibleAuthorizationPolicyProvider — Dynamically creates AuthorizationPolicy instances for scoped permission policies on demand
  • PermissionAuthorizationHandler — Evaluates PermissionAuthorizationRequirement by checking if the user's per-scope permission claim satisfies the required bitmask
  • EfCoreUserClaimsPrincipalFactory — Enriches the user's ClaimsPrincipal with permissions_{Scope} claims for the EF Core provider
  • MongoUserClaimsPrincipalFactory — Enriches the user's ClaimsPrincipal with permissions_{Scope} claims for the MongoDB provider

Swagger Support

Call AddAuthOptions() on SwaggerGenOptions to add Bearer token security definitions:

builder.Services.AddSwaggerGen(options => options.AddAuthOptions());

Installation

dotnet add package AugusteVN.Modules.Auth.Api

Full Documentation

See the Auth Module README for complete documentation.

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

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.7 76 8/9/2026
1.0.4 78 8/9/2026
1.0.3 77 8/9/2026
1.0.2 81 8/8/2026
1.0.1 78 8/8/2026
1.0.0 80 8/8/2026