Skip to content

EasyAbp/Abp.AspNetCoreRateLimit

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.

Abp.AspNetCoreRateLimit

ABP version NuGet NuGet Download Discord online GitHub stars

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

Installation

  1. Install the following NuGet packages. (see how)

    • 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)

  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