Do CSRF attacks apply to API's?

后端 未结 5 1486
误落风尘
误落风尘 2020-12-01 00:04

In particular, I\'m writing a Django RESTful API to back an iOS application, and I keep running into Django\'s CSRF protections whenever I write methods to deal with POST re

5条回答
  •  醉梦人生
    2020-12-01 00:21

    They do apply if you're also using your API to support a website.

    In this case you still need some form of CSRF protection to prevent someone embedding requests in other sites to have drive-by effects on an authenticated user's account.

    Chrome seems to deny cross-origin POST requests by default (other browsers may not be so strict), but allows GET requests cross-origin so you must make sure any GET requests in your API don't have side-effects.

提交回复
热议问题