简体   繁体   中英

php class to protect api from CSRF requests

I'm looking for a PHP class to protect my RESTful API from CSRF attacks. I have seen many classes for that but all of them are used for normal pages NOT a RESTful API.

You write your own. Every response your api sends should have a header which is set to a long alphanumeric string. The next request you receive should contain that header. You can use a simple table for persistance.

OWASP gives a nice example implementation that you could use

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM