AugusteVN.Modules.Auth.Api
1.0.1
See the version list below for details.
dotnet add package AugusteVN.Modules.Auth.Api --version 1.0.1
NuGet\Install-Package AugusteVN.Modules.Auth.Api -Version 1.0.1
<PackageReference Include="AugusteVN.Modules.Auth.Api" Version="1.0.1" />
<PackageVersion Include="AugusteVN.Modules.Auth.Api" Version="1.0.1" />
<PackageReference Include="AugusteVN.Modules.Auth.Api" />
paket add AugusteVN.Modules.Auth.Api --version 1.0.1
#r "nuget: AugusteVN.Modules.Auth.Api, 1.0.1"
#:package AugusteVN.Modules.Auth.Api@1.0.1
#addin nuget:?package=AugusteVN.Modules.Auth.Api&version=1.0.1
#tool nuget:?package=AugusteVN.Modules.Auth.Api&version=1.0.1
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
UserandRoleentities - FluentValidation validators from the
_Sharedassembly - SMTP configuration (
SmtpConfig) andIdentityConfig(frontend URLs for email links) IEmailSender<TUser>asIdentityEmailSender<TUser>backed bySmtpMailerPermissionAuthorizationHandlerandFlexibleAuthorizationPolicyProviderfor claims-based scoped authorization- Provider-specific
UserClaimsPrincipalFactorythat 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:
EfCoreUserClaimsPrincipalFactoryorMongoUserClaimsPrincipalFactory— enrichesClaimsPrincipalwithpermissions_{Scope}claimsIdentityEmailSender<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 viaPolicyNameHelperFlexibleAuthorizationPolicyProvider— Dynamically createsAuthorizationPolicyinstances for scoped permission policies on demandPermissionAuthorizationHandler— EvaluatesPermissionAuthorizationRequirementby checking if the user's per-scope permission claim satisfies the required bitmaskEfCoreUserClaimsPrincipalFactory— Enriches the user'sClaimsPrincipalwithpermissions_{Scope}claims for the EF Core providerMongoUserClaimsPrincipalFactory— Enriches the user'sClaimsPrincipalwithpermissions_{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 | Versions 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. |
-
net10.0
- AugusteVN.Api.Auth.Extensions (>= 1.1.0)
- AugusteVN.Api.EndpointFilters (>= 1.1.0)
- AugusteVN.CQRS.Extensions (>= 1.1.0)
- AugusteVN.MailKit.SmtpMailer (>= 1.2.0)
- AugusteVN.Modules.Auth._Shared (>= 1.0.1)
- AugusteVN.Modules.Auth.Database.EfCore (>= 1.0.1)
- AugusteVN.Modules.Auth.Database.Mongo (>= 1.0.1)
- AugusteVN.Modules.Auth.Features (>= 1.0.1)
- FluentValidation.DependencyInjectionExtensions (>= 12.1.1)
- MailKit (>= 4.17.0)
- Microsoft.OpenApi (>= 1.6.22)
- Swashbuckle.AspNetCore (>= 6.5.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.