Abp.AspNetCoreRateLimit
Abp.AspNetCoreRateLimit copied to clipboard
An Abp module helps you control how often your service is used.
trafficstars
Abp.AspNetCoreRateLimit
An Abp module helps you control how often your service is used.
Installation
-
Install the following NuGet packages. (see how)
- EasyAbp.Abp.AspNetCoreRateLimit.AspNetCoreRateLimit
- EasyAbp.Abp.AspNetCoreRateLimit.AspNetCoreRateLimit.Client
- EasyAbp.Abp.AspNetCoreRateLimit.AspNetCoreRateLimit.Ip
-
Add
DependsOn(typeof(AbpClientLimiterModule))andDependsOn(typeof(AbpIpLimiterModule))attribute to configure the module dependencies. (see how) -
Extends IHostBuilder with Limiter configuration methods.
IHostBuilder.UseAspNetCoreRateLimitIp(); IHostBuilder.UseAspNetCoreRateLimitClient(); -
Register the middleware below within the
OnApplicationInitialization()method ofAppModule.cs"before" theUseRouting()middleware:app.UseIpRateLimiting(); app.UseClientRateLimiting(); -
Add the following code at
ConfigureServices()methodcontext.Services.AddLimiterService<MemoryCacheRateLimitCounterStore>(service => { service.AddLimiterIpService<MemoryCacheIpPolicyStore>(); service.AddLimiterClientService<MemoryCacheClientPolicyStore>(); });
Documentation
Rate limiting based on client IP
Rate limiting based on client ID
Advanced configuration
- Customize the quoata exceeded response
- IP / ClientId resolve contributors
- Use Redis as a distributed counter store
Roadmap
- [ ] Unit test