开发者

"Are you a human" type of page in django

In order to prevent DOS type of attacks to my django site, I am considering to show a Captcha page if my web app things it is hit by a certain IP too often. Similar to what SO i开发者_StackOverflow社区s doing when you show too mach activity.

How is the best way to do that in django? My initial ideas so far are

  1. A decorator in front of every view
  2. A custom django middleware

What would you suggest? Maybe there exist already django apps for that?


You are right, there are existing Django Apps which do this. Try to "design" (not code) the whole thing yourself & then look at how these apps are implemented. You'll learn this way. Here are the links

  1. django-simple-captcha
  2. django-captcha
  3. django captcha & images


A custom middleware would be best. If I understood your requirements, you want to both log how often the IP hits the web app and then to show the Captcha page for authorization.

Keep in mind that this will keep Google and other search engine bots out as well if you won't add anything to deal with them specifically (e.g. User agent checking etc).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜