# Abp.AspNetCoreRateLimit

NuGet (opens new window) NuGet Download (opens new window) GitHub stars (opens new window)

An Abp module helps you control how often your service is used.

# Installation

  1. Install the following NuGet packages. (see how (opens new window))

    • EasyAbp.Abp.AspNetCoreRateLimit.AspNetCoreRateLimit
    • EasyAbp.Abp.AspNetCoreRateLimit.AspNetCoreRateLimit.Client
    • EasyAbp.Abp.AspNetCoreRateLimit.AspNetCoreRateLimit.Ip
  2. Add DependsOn(typeof(AbpClientLimiterModule)) and DependsOn(typeof(AbpIpLimiterModule)) attribute to configure the module dependencies. (see how (opens new window))

  3. Extends IHostBuilder with Limiter configuration methods.

    IHostBuilder.UseAspNetCoreRateLimitIp();
    IHostBuilder.UseAspNetCoreRateLimitClient();
    
  4. Register the middleware below within the OnApplicationInitialization() method of AppModule.cs "before" the UseRouting() middleware:

    app.UseIpRateLimiting();
    app.UseClientRateLimiting();
    
  5. Add the following code at ConfigureServices() method

    context.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

# Roadmap

  • [ ] Unit test
Last Updated: 8/20/2020, 9:41:48 AM