简体   繁体   English

php class 保护 api 免受 CSRF 请求

[英]php class to protect api from CSRF requests

I'm looking for a PHP class to protect my RESTful API from CSRF attacks.我正在寻找 PHP class 来保护我的 RESTful API 免受 CSRF 攻击。 I have seen many classes for that but all of them are used for normal pages NOT a RESTful API.我见过很多类,但它们都用于普通页面而不是 RESTful API。

You write your own.你自己写。 Every response your api sends should have a header which is set to a long alphanumeric string.您的 api 发送的每个响应都应该有一个设置为长字母数字字符串的 header。 The next request you receive should contain that header.您收到的下一个请求应包含该 header。 You can use a simple table for persistance.您可以使用简单的表进行持久化。

OWASP gives a nice example implementation that you could use OWASP提供了一个很好的示例实现,您可以使用它

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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