MinimalApi.Identity.API 1.0.233

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

Packages MinimalApi Identity API

Library for dynamically managing users, roles, claims, modules and license, using .NET 8 Minimal API, Entity Framework Core and SQL Server.

This library is still under development of new implementations.

🏗️ ToDo

  • Add endpoint for password change (Reset Password)
  • Add endpoints for two-factor authentication and management
  • Add endpoints for downloading and deleting personal data
  • Test endpoints to impersonate the user
  • Add API documentation

🔜 Future implementations

  • Replacing the hosted service authorization policy updater using Coravel jobs
  • Add support for relational databases other than MS SQLServer (e.g. MySQL and PostgreSQL)
  • Add support for multi tenancy
  • Add authentication support from third-party providers (e.g. GitHub, Azure)

🛠️ Installation

The library is available on NuGet, just search for MinimalApi.Identity.API in the Package Manager GUI or run the following command in the .NET CLI:

dotnet add package MinimalApi.Identity.API

🚀 Configuration

Adding this sections in the appsettings.json file:

{
    "Logging": {
        "LogLevel": {
            "Default": "Information",
            "Microsoft.AspNetCore": "Warning"
        }
    },
    "Kestrel": {
        "Limits": {
            "MaxRequestBodySize": 5242880
        }
    },
    "JwtOptions": {
        "Issuer": "[ISSUER]",
        "Audience": "[AUDIENCE]",
        "SecurityKey": "[SECURITY-KEY-512-CHAR]",
        "AccessTokenExpirationMinutes": 60,
        "RefreshTokenExpirationMinutes": 60
    },
    "NetIdentityOptions": {
        "RequireUniqueEmail": true,
        "RequireDigit": true,
        "RequiredLength": 8,
        "RequireUppercase": true,
        "RequireLowercase": true,
        "RequireNonAlphanumeric": true,
        "RequiredUniqueChars": 4,
        "RequireConfirmedEmail": true,
        "MaxFailedAccessAttempts": 3,
        "AllowedForNewUsers": true,
        "DefaultLockoutTimeSpan": "00:05:00"
    },
    "SmtpOptions": {
        "Host": "smtp.example.org",
        "Port": 25,
        "Security": "StartTls",
        "Username": "Username del server SMTP",
        "Password": "Password del server SMTP",
        "Sender": "MyApplication <noreply@example.org>",
        "SaveEmailSent": true
    },
    "UsersOptions": {
        "AssignAdminRoleOnRegistration": "admin@example.org",
        "PasswordExpirationDays": 90
    },
    "ApiValidationOptions": {
        "MinLengthFirstName": 3,
        "MaxLengthFirstName": 50,
        "MinLengthLastName": 3,
        "MaxLengthLastName": 50,
        "MinLengthUsername": 5,
        "MaxLengthUsername": 20,
        "MinLengthRoleName": 5,
        "MaxLengthRoleName": 20,
        "MinLengthModuleName": 5,
        "MaxLengthModuleName": 20,
        "MinLengthModuleDescription": 5,
        "MaxLengthModuleDescription": 100,
        "MinLengthLicenseName": 5,
        "MaxLengthLicenseName": 20,
        "MinLengthClaimValue": 5,
        "MaxLengthClaimValue": 20,
        "MinLengthPolicyName": 5,
        "MaxLengthPolicyName": 20,
        "MinLengthPolicyDescription": 5,
        "MaxLengthPolicyDescription": 100
    },
    "HostedServiceOptions": {
        "IntervalAuthPolicyUpdaterMinutes": 5
    },
    "ConnectionStrings": {
        "DefaultConnection": "Data Source=[HOSTNAME];Initial Catalog=[DATABASE];User ID=[USERNAME];Password=[PASSWORD];Encrypt=False"
    }
}

If SaveEmailSent is false, only emails that failed while sending will be saved, if SaveEmailSent is true, both emails that were sent successfully and emails that failed will be saved

Registering services at Program.cs file

var builder = WebApplication.CreateBuilder(args);
var authConnection = builder.Configuration.GetDatabaseConnString("DefaultConnection");
var formatErrorResponse = ErrorResponseFormat.List; // or ErrorResponseFormat.Default

builder.Services.AddCors(options => options.AddPolicy("cors", builder
    => builder.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader()));

//...

//If you need to register additional services(transient, scoped, singleton) in dependency injection,
//you can use the related extension methods exposed by the library.

//NOTE: Service has already been used within the library to register the necessary services, it is
//recommended to use a different nomenclature.

//The library exposes the following extension methods that leverage the Scrutor package:
//- Transient lifecycle => builder.Services.AddRegisterTransientService<IAuthService>("Service");
//- Scoped lifecycle => builder.Services.AddRegisterScopedService<IAuthService>("Service");
//- Singleton lifecycle => builder.Services.AddRegisterSingletonService<IAuthService>("Service");

builder.Services.AddRegisterServices<Program>(builder.Configuration, authConnection, formatErrorResponse);
builder.Services.AddAuthorization(options =>
{
    // Here you can add additional authorization policies
});

//...

var app = builder.Build();
app.UseHttpsRedirection();

//Use this MinimalApiExceptionMiddleware in your pipeline if you don't need to add new exceptions.
app.UseMiddleware<MinimalApiExceptionMiddleware>();

//If you need to add more exceptions, you need to add the ExtendedExceptionMiddleware middleware to your pipeline.
//In the demo project, in the Middleware folder, you can find an example implementation, which you can use to add
//the exceptions you need.
//app.UseMiddleware<ExtendedExceptionMiddleware>();

if (app.Environment.IsDevelopment())
{
    app.UseSwagger()
        .UseSwaggerUI(options =>
        {
            options.SwaggerEndpoint("/swagger/v1/swagger.json", builder.Environment.ApplicationName);
        });
}

app.UseStatusCodePages();
app.UseRouting();

app.UseCors("cors");

app.UseAuthentication();
app.UseAuthorization();

app.UseMapEndpoints();
app.Run();

📡 API Reference

See the documentation for a list of all available API endpoints.

📚 Demo

You can find a sample project in the example project.

📦 Dependencies

📝 License

This project is licensed under the MIT License - see the LICENSE file for details.

⭐ Give a Star

Don't forget that if you find this project useful, put a ⭐ on GitHub to show your support and help others discover it.

🤝 Contributing

The project is constantly evolving. Contributions are always welcome. Feel free to report issues and pull requests on the repository.

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 was computed.  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 was computed.  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.246 121 7/10/2025
1.0.245 130 7/4/2025
1.0.243 131 6/29/2025
1.0.234 132 6/14/2025
1.0.233 253 6/13/2025
1.0.232 273 6/10/2025
1.0.231 152 5/25/2025
1.0.227 189 5/16/2025
1.0.226 142 5/5/2025
1.0.218 158 4/28/2025
1.0.212 152 4/21/2025
1.0.210 104 4/19/2025
1.0.207 190 4/17/2025
1.0.203 196 4/15/2025
1.0.196 197 4/14/2025
1.0.191 110 4/11/2025
1.0.185 131 4/11/2025
1.0.176 161 4/10/2025
1.0.175 162 4/7/2025
1.0.172 164 4/7/2025
1.0.164 84 4/5/2025
1.0.156 176 4/3/2025
1.0.152 161 4/2/2025
1.0.147 171 4/1/2025
1.0.141 167 3/30/2025
1.0.135 164 3/29/2025
1.0.128 147 3/27/2025
1.0.94 78 3/22/2025
1.0.86 161 3/20/2025
1.0.37 175 3/8/2025
1.0.16 224 3/5/2025
1.0.12 218 3/4/2025
1.0.11 212 3/4/2025
1.0.4 103 3/1/2025
1.0.3 105 2/27/2025
1.0.2 108 2/27/2025
1.0.1 100 2/27/2025