IP whitelisting in bucket4j

746 views Asked by At

I am using bucket4j in my spring boot application to prevent DOS attacks where if an ip makes a lots of requests in a minute, it is blocked. I am using following config for that

bucket4j.enabled=true
bucket4j.filters[0].cache-name=buckets
bucket4j.filters[0].filter-method=servlet
bucket4j.filters[0].http-response-body={ "message": "Too many requests" }
bucket4j.filters[0].url=.*
bucket4j.filters[0].strategy=first
bucket4j.filters[0].rate-limits[0].bandwidths[0].capacity=20
bucket4j.filters[0].rate-limits[0].bandwidths[0].time=1
bucket4j.filters[0].rate-limits[0].bandwidths[0].unit=minutes

But there is an IP that is actually supposed to make a lot of calls. How can I whitelist that IP?

1

There are 1 answers

0
Matheus Santz On

There are examples in this link of passing bean method parameters to properties: https://github.com/MarcGiffing/bucket4j-spring-boot-starter

It would be like this:

bucket4j.filters[0].rate-limits[0][email protected]()