@@ -54,6 +54,36 @@ public function forms_endpoint_is_rate_limited()
5454 $ this ->post ('/!/forms/contact ' )->assertRateLimited ();
5555 }
5656
57+ #[Test]
58+ public function cp_login_endpoint_is_rate_limited ()
59+ {
60+ collect (range (1 , 4 ))->each (fn () => $ this ->post ('/cp/auth/login ' )->assertNotRateLimited ());
61+ $ this ->post ('/cp/auth/login ' )->assertRateLimited ();
62+ }
63+
64+ #[Test]
65+ public function cp_password_email_endpoint_is_rate_limited ()
66+ {
67+ collect (range (1 , 4 ))->each (fn () => $ this ->post ('/cp/auth/password/email ' )->assertNotRateLimited ());
68+ $ this ->post ('/cp/auth/password/email ' )->assertRateLimited ();
69+ }
70+
71+ #[Test]
72+ public function cp_password_reset_endpoint_is_rate_limited ()
73+ {
74+ collect (range (1 , 4 ))->each (fn () => $ this ->post ('/cp/auth/password/reset ' )->assertNotRateLimited ());
75+ $ this ->post ('/cp/auth/password/reset ' )->assertRateLimited ();
76+ }
77+
78+ #[Test]
79+ public function cp_and_frontend_auth_have_independent_buckets ()
80+ {
81+ collect (range (1 , 4 ))->each (fn () => $ this ->post ('/!/auth/login ' )->assertNotRateLimited ());
82+ $ this ->post ('/!/auth/login ' )->assertRateLimited ();
83+
84+ $ this ->post ('/cp/auth/login ' )->assertNotRateLimited ();
85+ }
86+
5787 #[Test]
5888 public function auth_rate_limiter_can_be_overridden ()
5989 {
@@ -65,6 +95,29 @@ public function auth_rate_limiter_can_be_overridden()
6595 $ this ->post ('/!/auth/login ' )->assertRateLimited ();
6696 }
6797
98+ #[Test]
99+ public function cp_auth_rate_limiter_inherits_overrides_to_statamic_auth ()
100+ {
101+ RateLimiter::for ('statamic.auth ' , fn ($ request ) => Limit::perMinute (2 )->by ($ request ->ip ()));
102+
103+ $ this ->post ('/cp/auth/login ' )->assertNotRateLimited ();
104+ $ this ->post ('/cp/auth/login ' )->assertNotRateLimited ();
105+ $ this ->post ('/cp/auth/login ' )->assertRateLimited ();
106+ }
107+
108+ #[Test]
109+ public function cp_auth_rate_limiter_can_be_overridden_independently ()
110+ {
111+ RateLimiter::for ('statamic.cp.auth ' , fn ($ request ) => Limit::perMinute (2 )->by ($ request ->ip ()));
112+
113+ $ this ->post ('/cp/auth/login ' )->assertNotRateLimited ();
114+ $ this ->post ('/cp/auth/login ' )->assertNotRateLimited ();
115+ $ this ->post ('/cp/auth/login ' )->assertRateLimited ();
116+
117+ // Frontend auth still uses the default 4/min
118+ collect (range (1 , 4 ))->each (fn () => $ this ->post ('/!/auth/login ' )->assertNotRateLimited ());
119+ }
120+
68121 #[Test]
69122 public function forms_rate_limiter_can_be_overridden ()
70123 {
0 commit comments