<p>Problem: 
I have a JSON endpoint and like to limit access to it. 
I.e. to prevent double submits on contact forms or brute force attempts. </p>

<p>One solution that came to my mind was rate-limiting the requests, but I did not find a Craft way to archive this with my controllers. </p>

<p>Another idea was to set the CSRF token to invalid after X requests. 
Any help would be highly appreciated. </p>

CC BY-SA 4.0
2020-01-24T19:20:38.443Z
Not a real answer, but there's is a guide on how to do it in Yii (which is the framework Craft uses) here that might be helpful: https://www.yiiframework.com/doc/guide/2.0/en/rest-rate-limiting
Brad Bell
CC BY-SA 4.0
2020-01-27T10:53:57.170Z
I was aware of the option, since craft has their very own implementation of the user model, i do not see any chance to use the behavior of yii. (please correct me if am wrong)
nfo
<json><security><api>
Rest Controller and API Rate Limits or how to set CSRF token invalid
# Rest Controller and API Rate Limits or how to set CSRF token invalid

(Asked by: username_0 on 2020-01-24)

Problem:
I have a JSON endpoint and like to limit access to it.
I.e. to prevent double submits on contact forms or brute force attempts.

One solution that came to my mind was rate-limiting the requests, but I did not find a Craft way to archive this with my controllers.

Another idea was to set the CSRF token to invalid after X requests.
Any help would be highly appreciated.

**Tags:** json, security, api
> **Comments:**
> **username_1**: Not a real answer, but there's is a guide on how to do it in Yii (which is the framework Craft uses) here that might be helpful: https://www.yiiframework.com/doc/guide/2.0/en/rest-rate-limiting  
> **username_0**: I was aware of the option, since craft has their very own implementation of the user model, i do not see any chance to use the behavior of yii. (please correct me if am wrong)  

---

## 0 answers

