简体   繁体   English

Zend Framework 2-CSRF令牌服务器端验证

[英]Zend Framework 2 - CSRF Token Server-side validation

I've got the following issue on my mind: I built some kind of generic fieldset which I want to use in all my standard forms. 我想到了以下问题:我建立了某种通用字段集,希望将其用于所有标准格式中。 It contains a CSRF-Token and a Submit-Button . 它包含一个CSRF-Token和一个Submit-Button

It works great on the client side. 它在客户端上很好用。 But I wonder: If I use this Zend\\Form\\Element\\Csrf where is my logic to proof on the server side that this token is ok. 但是我想知道:如果我使用这个Zend\\Form\\Element\\Csrf ,在服务器端证明该令牌可以的逻辑是什么。 Or is this handled by Zend somewhere in the background? 还是由Zend在后台的某个地方处理?

Thanks! 谢谢!

I use this token and had the same question. 我使用此令牌,并有相同的问题。 The short and sweet answer is that it is handled in the background. 简短而甜蜜的答案是,它是在后台处理的。

If the token is not correct or if it expires, an error message will be returned. 如果令牌不正确或令牌过期,将返回错误消息。 Most likely stating that the form did not originate from the proper location. 最有可能说明表格不是来自正确的位置。

You can test it by using a proxy, burpsuite is one. 您可以使用代理进行测试,burpsuite是其中之一。 Submit the form, intercept it in the proxy, change the token, pass it on to the server. 提交表单,在代理中拦截它,更改令牌,然后将其传递给服务器。 It should be rejected. 它应该被拒绝。

Or you can use something like Zend debugger and trace it. 或者,您可以使用Zend调试器之类的东西进行跟踪。 Either way you should know with confidence that it is handled correctly. 无论哪种方式,您都应该自信地知道它已正确处理。

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

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