Post Execution Condition #263
-
Hello, I have somes questions regarding #71, one of them might be an issue, but we'll see. @MarcGiffing, you was on it, maybe you could elaborate?:
I can still request as many times without |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
If the security filter rejects the the request with a 401 you must use two filters. The first one for unauthenticated users and the second one for the authenticated users:
|
Beta Was this translation helpful? Give feedback.
-
Hi, authenticated and anonymous users cannot access same resource without a 401,
In all scenarios every request must consume a request for DoS prevention, not only when request comes 401. Your below configuration rate limits everyone under capacity 2, since every request comes before spring security that executes for all users.
Maybe I figured the solution, but not sure if that's correct, would you approve this:
Now if user gets 403 (meaning anonymous?) he is capped for capacity 2. Otherwise I move on (meaning he must be authenticated), I can use filter-order: 1, now I can check based on anything I wish, since I have auth context? |
Beta Was this translation helpful? Give feedback.
Sorry I forgot to add the post-execute-condition in my proposal. Yes your solution seems to fit your problem if the first filter is executed before Spring security (which should be the default). I tried to visualize the post-execute-condition in the Readme
Image
If you sometimes may get a 401 status code my suggestion for improvement is to call a service which checks is the user is authenticated. Then your independent from the status code.
To prevent attacks you should consider to add multiple rate limit configurations:
https://bucket4j.com/8.9.0/toc.html#short-timed-bursts