@@ -46,55 +46,6 @@ public function register_rest_endpoint() {
4646 );
4747 }
4848
49- /**
50- * Permission callback.
51- *
52- * @param string $token The token.
53- *
54- * @return bool
55- */
56- public function validate_token ( $ token ) {
57- // Rate limiting: Check for too many failed attempts.
58- $ ip_address = $ this ->get_client_ip ();
59- $ rate_limit_key = 'prpl_api_rate_limit_tasks_ ' . \md5 ( $ ip_address );
60- $ failed_attempts = (int ) \get_transient ( $ rate_limit_key );
61-
62- // Block if more than 10 failed attempts in the last hour.
63- if ( $ failed_attempts >= 10 ) {
64- return false ;
65- }
66-
67- $ token = \str_replace ( 'token/ ' , '' , $ token );
68-
69- // Check test token first (use hash_equals to prevent timing attacks).
70- $ test_token = \get_option ( 'progress_planner_test_token ' , '' );
71- if ( ! empty ( $ test_token ) && \hash_equals ( $ test_token , $ token ) ) {
72- // Clear failed attempts on successful authentication.
73- \delete_transient ( $ rate_limit_key );
74- return true ;
75- }
76-
77- $ license_key = \get_option ( 'progress_planner_license_key ' , false );
78- if ( ! $ license_key || 'no-license ' === $ license_key ) {
79- // Increment failed attempts counter.
80- \set_transient ( $ rate_limit_key , $ failed_attempts + 1 , HOUR_IN_SECONDS );
81- return false ;
82- }
83-
84- // Use hash_equals() to prevent timing attacks.
85- $ is_valid = \hash_equals ( $ license_key , $ token );
86-
87- if ( ! $ is_valid ) {
88- // Increment failed attempts counter.
89- \set_transient ( $ rate_limit_key , $ failed_attempts + 1 , HOUR_IN_SECONDS );
90- } else {
91- // Clear failed attempts on successful authentication.
92- \delete_transient ( $ rate_limit_key );
93- }
94-
95- return $ is_valid ;
96- }
97-
9849 /**
9950 * Get task recommendations.
10051 *
0 commit comments