Rate limit rules based on whether or not a request is to an endpoint that needs authentication
See original GitHub issueHello,
I was wondering if I could get some help with/pointers for implementing rate limiting based on whether or not a request is hitting an api endpoint that needs authentication?
I thought I could add a GeneralRules
section to my appsettings.json
file, where I start off with with the first rule targeting * and then get more specific, and override it, but it doesnt seem to work :
{
"Endpoint": "*",
"Period": "1h",
"Limit": 60
},
{
"Endpoint": "*:/my-non-authenticated-endpoint",
"Period": "1h",
"Limit": 120
},
So that by default all my endpoints except for my-non-authenticated-endpoint
would have the first rule, and my-non-authenticated-endpoint
would have my second rule, but it doesnt seem to work that way? or do I have bad rules? I’m going off of IpRateLimiting with Redis, if it makes a difference.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5
Top Results From Across the Web
AspNetCoreRateLimit and rate limit rules based on ...
AspNetCoreRateLimit and rate limit rules based on whether or not a request is to an endpoint that needs authentication.
Read more >Rate Limit Policy
To ensure the quality of Auth0's services, the Auth0 APIs are subject to rate limiting. Depending on the API endpoint, the request limit...
Read more >load balancing - Rate limiting *un*-authenticated requests
Another approach to rate limiting you can take is to require a proof of work for any unauthenticated requests.
Read more >Rate-based rule statement
The rule aggregates requests according to your criteria, and counts and rate limits the aggregate groupings, based on the rule's limit and action...
Read more >Rate limiting best practices - WAF
These two rate limiting rules match requests performing a selected action (look up price, in this example) and use IP as the counting ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Sorry, i was being dense. I got what I needed by using
app.UseWhen(x => x.User.Identity.IsAuthenticated, builder => builder.UseClientRateLimiting());
app.UseWhen(x => !x.User.Identity.IsAuthenticated, builder => app.UseIpRateLimiting());
and configuring both
ClientRateLimiting
andIpRateLimiting
settings in my appSettings.json file@dupuis2387 d Did you explored if there any way to override
ResolveClientAsync(HttpContext httpContext)
to use custom-client-id or ip-address based on a if-else condition?