CoreSystem.RateLimiting 1.2.0

dotnet add package CoreSystem.RateLimiting --version 1.2.0
                    
NuGet\Install-Package CoreSystem.RateLimiting -Version 1.2.0
                    
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="CoreSystem.RateLimiting" Version="1.2.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CoreSystem.RateLimiting" Version="1.2.0" />
                    
Directory.Packages.props
<PackageReference Include="CoreSystem.RateLimiting" />
                    
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 CoreSystem.RateLimiting --version 1.2.0
                    
#r "nuget: CoreSystem.RateLimiting, 1.2.0"
                    
#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 CoreSystem.RateLimiting@1.2.0
                    
#: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=CoreSystem.RateLimiting&version=1.2.0
                    
Install as a Cake Addin
#tool nuget:?package=CoreSystem.RateLimiting&version=1.2.0
                    
Install as a Cake Tool

⚡ CoreSystem.RateLimiting

NuGet Downloads License .NET OpenTelemetry

CoreSystem.RateLimiting is a production-ready fixed-window rate-limiting package for ASP.NET Core APIs. It protects APIs with a global limiter that partitions authenticated requests by subject and anonymous requests by client IP address.

The package returns RFC 7807 Problem Details responses, exposes rejection metrics through OpenTelemetry, and remains safe behind trusted reverse proxies when the consuming API configures forwarded headers correctly.


✨ Features

  • ✅ Global fixed-window rate limiter
  • ✅ Partitioning by authenticated subject claim
  • ✅ Remote-IP fallback for anonymous requests
  • ✅ RFC 7807 429 Too Many Requests responses
  • ✅ Retry-After response header when available
  • ✅ Configurable permits, window, queue, and claim type
  • ✅ Built-in structured rejection logging
  • ✅ OpenTelemetry metrics through IObservabilityContributor
  • ✅ Safe reverse-proxy integration guidance

📦 Installation

dotnet add package CoreSystem.RateLimiting

🚀 Quick Start

using Core.RateLimiting.DependencyInjection;

builder.Services.AddCoreRateLimiting(options =>
{
    options.PermitLimit = 100;
    options.Window = TimeSpan.FromMinutes(1);
    options.QueueLimit = 0;
    options.SubjectClaimType = "sub";
});

app.UseForwardedHeaders();
app.UseAuthentication();
app.UseCoreRateLimiting();
app.UseAuthorization();

⚙️ Configuration

Option Default Description
Enabled true Enables the limiter registration and middleware.
PolicyName core-fixed-window Policy identifier included in logs, metrics, and Problem Details extensions.
PermitLimit 100 Requests allowed per partition in each window.
Window 1 minute Fixed-window duration.
QueueLimit 0 Number of requests allowed to wait for a permit.
QueueProcessingOrder OldestFirst Queue discipline when queueing is enabled.
AutoReplenishment true Enables automatic window replenishment.
SubjectClaimType ClaimTypes.NameIdentifier Claim used to identify authenticated callers.

🔗 Configuration Binding

Use CopyFrom to bind configuration into a source instance and apply every option during registration without mapping properties one by one.

var configuredOptions = builder.Configuration
    .GetSection("Core:RateLimiting")
    .Get<RateLimitingOptions>()
    ?? new RateLimitingOptions();

builder.Services.AddCoreRateLimiting(options =>
    options.CopyFrom(configuredOptions));

🔒 Client Identity and Reverse Proxies

Requests are partitioned by subject:<claim-value> when authenticated, otherwise by ip:<remote-address>.

Forwarded-header trust belongs to the consuming API because proxy addresses and networks are deployment-specific. Configure KnownProxies and/or KnownNetworks, and call UseForwardedHeaders() before authentication and rate limiting. Never use an arbitrary client-provided X-Forwarded-For value as a rate-limit identity.


🚫 Rejection Response

When the permit limit is exhausted, the middleware returns HTTP 429 with application/problem+json.

{
  "type": "https://httpstatuses.com/429",
  "title": "Too Many Requests",
  "status": 429,
  "detail": "The request rate limit has been exceeded.",
  "policy": "management-api",
  "retryAfterSeconds": 42
}

Retry-After is also emitted when the underlying rate limiter provides retry metadata.


📊 Built-in Observability

The package publishes the Core.RateLimiting meter and registers it through IObservabilityContributor for CoreSystem.Observability integration.

Metric Type Tags
rate_limiting.rejected_requests Counter rate_limit.policy

Rejections are also logged as structured warnings with the policy name and retry delay. Client identities are deliberately excluded from metric tags to avoid high-cardinality and privacy-sensitive telemetry.


📚 Documentation

The complete documentation includes Getting Started, configuration, reverse-proxy safety, rejection responses, and OpenTelemetry observability.


🤝 Contributing

Contributions, bug reports, and feature requests are welcome.


📄 License

MIT License © Federin Pastor Gutierrez Ortiz

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.2.0 122 9/19/2026