AspNetCoreRateLimit icon indicating copy to clipboard operation
AspNetCoreRateLimit copied to clipboard

"group" endpoints into one rule

Open davedesantis opened this issue 2 years ago • 2 comments

I have the following configuration:

"ClientRateLimitSettings": {
  "EnableEndpointRateLimiting": true,
  "EnableRegexRuleMatching": true,
  "ClientIdHeader": "X-ClientId",
  "HttpStatusCode": 429,
  "QuotaExceededMessage": "{0}/{1}",
  "GeneralRules": [
    {
      "Endpoint": "get:/api/test",
      "Period": "1m",
      "Limit": 20
    }
  ]
},

The customer wishes to group all endpoints under /api/test under one rule, so basically, if I call GET /api/test/123 20 times, after that requests to GET /api/test/456 and GET /api/test should be blocked, too.

I tried with wildcards, and I tried with RegEx ("Endpoint": "get:/api/test/(.*)"), however it seems like every endpoint (so /123 and /456) is treated separately.

I don't know if I am missing something or if that's really not possible?

davedesantis avatar Mar 24 '22 11:03 davedesantis

Any update?

alannsiqueira avatar Sep 15 '22 16:09 alannsiqueira

Solution described here: https://github.com/stefanprodan/AspNetCoreRateLimit/issues/78

rwb196884 avatar Dec 06 '22 11:12 rwb196884