File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -55,6 +55,15 @@ def test_with_context_with_cache():
5555 assert thread_cache .stats .rate_limited_hits == 0
5656
5757
58+ def test_bypassed_ip_skips_user_blocking ():
59+ test_utils .generate_and_set_context (user = {"id" : "123" }, ip = "1.2.3.4" )
60+ thread_cache = get_cache ()
61+ thread_cache .config .blocked_uids = ["123" ]
62+ thread_cache .config .set_bypassed_ips (["1.2.3.4" ])
63+
64+ assert should_block_request () == {"block" : False }
65+
66+
5867def test_cache_comms_with_endpoints ():
5968 test_utils .generate_and_set_context (user = {"id" : "456" }, route = "/posts/:id" )
6069 set_rate_limit_group ("my_group" )
Original file line number Diff line number Diff line change @@ -32,6 +32,10 @@ def should_block_request():
3232 context .executed_middleware = True
3333 context .set_as_current_context ()
3434
35+ # Bypassed IPs skip user blocking and rate limiting
36+ if cache .is_bypassed_ip (context .remote_address ):
37+ return {"block" : False }
38+
3539 # User blocking allows customers to easily take action when attacks are coming from specific accounts
3640 if context .user and cache .is_user_blocked (context .user ["id" ]):
3741 return {"block" : True , "type" : "blocked" , "trigger" : "user" }
You can’t perform that action at this time.
0 commit comments