Skip to content
This repository has been archived by the owner on Dec 22, 2024. It is now read-only.

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

License

Notifications You must be signed in to change notification settings

EasyAbp/Abp.AspNetCoreRateLimit

Repository files navigation

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