AT.BackEnd.Api
2.6.0
dotnet add package AT.BackEnd.Api --version 2.6.0
NuGet\Install-Package AT.BackEnd.Api -Version 2.6.0
<PackageReference Include="AT.BackEnd.Api" Version="2.6.0" />
<PackageVersion Include="AT.BackEnd.Api" Version="2.6.0" />
<PackageReference Include="AT.BackEnd.Api" />
paket add AT.BackEnd.Api --version 2.6.0
#r "nuget: AT.BackEnd.Api, 2.6.0"
#:package AT.BackEnd.Api@2.6.0
#addin nuget:?package=AT.BackEnd.Api&version=2.6.0
#tool nuget:?package=AT.BackEnd.Api&version=2.6.0
AT.BackEnd.Api
Este nuget expone una configuración transversal para las API Rest
Getting Started
- Proceso de instalación
- Software dependencies
- Cómo usarlo?
- API references
⚙️ Proceso de instalación:
Instale el nuget usando el siguiente comando.
.NET Cli
dotnet add package AT.BackEnd.Api --version 2.6.0
Nuget
NuGet\Install-Package AT.BackEnd.Api -Version 2.6.0
Package reference
<PackageReference Include="AT.BackEnd.Api" Version="2.6.0" />
🛠️Dependencias
net10.0
- Asp.Versioning.Http [10.0.1]
- Asp.Versioning.Mvc [10.0.1]
- Asp.Versioning.Mvc.ApiExplorer [10.0.1]
- AT.BackEnd.Application.CQRS [2.1.0]
- AT.Core.Entities [1.3.1]
- FluentValidation [12.1.1]
- FluentValidation.DependencyInjectionExtensions [12.1.1]
- Scalar.AspNetCore [2.16.17]
- Serilog.AspNetCore [10.0.0]
- Microsoft.AspNetCore.OpenApi [10.0.10]
- Meziantou.Analyzer [3.0.122]
- SonarAnalyzer.CSharp [10.31.0.145097]
- Roslynator.Analyzers [4.15.0]
✈️ Cómo usarlo?
Se recomienda instalar este nuget en un proyecto ASP.NET API Core
Program.cs
Registrar los servicios que se exponen en el metodo AddATApiCommon
public static void Main(string[] args)
{
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddATApiCommon(builder.Configuration);
⁝
Configurar los servicios por defecto.
⁝
var app = builder.Build();
app.ConfigureATApiCommon(new SettingsApi()));
⁝
Configurar middleware UserContext.
⁝
app.UseAuthentication();
app.UseAuthorization();
app.UseMiddleware<UserContextMiddleware>();
app.MapControllers();
⁝
🚦 Limite de peticiones
Viene activo sin hacer nada: AddATApiCommon registra el limitador y ConfigureATApiCommon
lo pone en el pipeline. No hay que llamar a UseRateLimiter ni acordarse del orden, de modo
que ninguna API se queda sin limite por olvido.
Como corre antes de UseAuthentication, las peticiones se cuentan por IP — que es lo que
cubre el abuso desde fuera. Si una API necesita contarlas por usuario, debe poner ella misma
app.UseRateLimiter() despues de UseAuthentication.
Para subir o bajar el limite no hace falta tocar codigo: basta con la configuracion (tabla mas
abajo). Para apagarlo, RateLimiting:Enabled = false.
Los endpoints que se pueden atacar por repeticion (login, refresh, OTP, recuperacion de contrasena) llevan ademas la politica estricta:
[EnableRateLimiting(AtRateLimitPolicies.Sensitive)] // en un controller
group.MapPost("/SignIn", HandleSignIn)
.RequireRateLimiting(AtRateLimitPolicies.Sensitive); // en minimal endpoints
Configuracion (appsettings.json o App settings del App Service):
| Clave | Default | Que hace |
|---|---|---|
RateLimiting:Enabled |
true |
Apaga el limite sin quitar el middleware |
RateLimiting:PermitLimit |
300 |
Peticiones por ventana del limite general |
RateLimiting:WindowSeconds |
60 |
Ventana del limite general |
RateLimiting:SensitivePermitLimit |
10 |
Peticiones por ventana de la politica estricta |
RateLimiting:SensitiveWindowSeconds |
60 |
Ventana de la politica estricta |
Al rechazar responde 429 con Retry-After y el mismo sobre ApiResponse del resto de la API.
🔐 HTTPS obligatorio (HSTS)
ConfigureATApiCommon emite Strict-Transport-Security fuera de desarrollo, para que el
navegador no vuelva a intentar HTTP contra la API. En desarrollo se omite a proposito: la
politica se cachea por dominio y dejaria localhost atado a HTTPS para cualquier otro
proyecto de la maquina.
Dos comportamientos de ASP.NET que conviene conocer al probarlo:
- La cabecera solo viaja en respuestas HTTPS; una peticion HTTP recibe antes el 307 de
UseHttpsRedirection. localhost,127.0.0.1y[::1]estan excluidos por defecto, asi que contra la maquina local no se vera aunque el entorno sea Production.
| Clave | Default | Que hace |
|---|---|---|
Hsts:Enabled |
true |
Apagarla deja max-age=0, con lo que el navegador olvida la politica |
Hsts:MaxAgeDays |
30 |
Cuanto la recuerda el navegador. Subir a 365 cuando el despliegue este estable |
Hsts:IncludeSubDomains |
false |
Extiende la politica a los subdominios |
Hsts:Preload |
false |
Postula el dominio a la lista de precarga de los navegadores |
MaxAgeDays arranca en 30 y no en 365 a proposito: mientras se valida el despliegue, un error
de certificado se corrige en semanas en vez de dejar clientes sin acceso durante un ano.
IncludeSubDomains y Preload quedan apagados porque sus efectos son dificiles de revertir.
🔒 Cabeceras de seguridad
ConfigureATApiCommon agrega X-Content-Type-Options, X-Frame-Options, Referrer-Policy,
X-Permitted-Cross-Domain-Policies y, en las respuestas que no son HTML, una
Content-Security-Policy restrictiva. No pisan un valor que la aplicacion haya definido antes,
y la interfaz de Scalar queda excluida de la CSP para que siga funcionando.
🎓 Créditos
Nombre del Paquete: AT.BackEnd.Api
Versión: 2.6.0
Autor
- Nombre: Dayser José Granados Pineda
- Correo Electrónico: djpgranados@gmail.com | daysergranados@hotmail.com
Licencia
Este paquete está bajo la licencia MIT License
Copyright (c) 2026 Dayser José Granados Pineda
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE..
Contacto
Si tienes comentarios, problemas o solicitudes, ¡no dudes en ponerte en contacto conmigo!
| 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
- Asp.Versioning.Http (>= 10.0.1)
- Asp.Versioning.Mvc (>= 10.0.1)
- Asp.Versioning.Mvc.ApiExplorer (>= 10.0.1)
- AT.BackEnd.Application.CQRS (>= 2.1.0)
- AT.Core.Entities (>= 1.3.1)
- FluentValidation (>= 12.1.1)
- FluentValidation.DependencyInjectionExtensions (>= 12.1.1)
- Scalar.AspNetCore (>= 2.16.17)
- Serilog.AspNetCore (>= 10.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 |
|---|---|---|
| 2.6.0 | 85 | 8/15/2026 |
| 2.5.0 | 99 | 8/15/2026 |
| 2.4.0 | 108 | 8/2/2026 |
| 2.3.1 | 110 | 8/1/2026 |
| 2.3.0 | 120 | 7/9/2026 |
| 2.2.0 | 462 | 12/8/2025 |
| 2.1.0 | 323 | 12/7/2025 |
| 2.0.0 | 297 | 11/21/2025 |
| 2.0.0-beta1 | 167 | 7/12/2025 |
| 1.5.0 | 177 | 6/28/2025 |
| 1.4.0 | 163 | 5/25/2025 |
| 1.3.0 | 230 | 4/1/2025 |
| 1.2.0 | 213 | 3/31/2025 |
| 1.1.0 | 531 | 3/24/2025 |
| 1.0.0 | 335 | 3/23/2025 |
Agrega HSTS activo fuera de desarrollo, configurable en la seccion Hsts (30 dias por defecto, sin subdominios ni preload).