doufei16736 2011-04-08 19:24
浏览 73

Symfony - 会话超时后提交登录页面上的CSRF字段为空,并提交不相关的表单

I'm using Symfony 1.4 with the sfGuardPlugin. If my session times out while I'm sitting on a page within the app, and I try to submit a form that is on that page, I will get redirected to the login page (this is good, because my session has timed out). But it thinks the login form has already been submitted, and that I've failed validation -- username, password, and CSRF are all missing and required.

Why does it think I've already submitted the login form, and why is the CSRF empty?

Now as a user I would be totally stuck, because I'm on the login page and the hidden CSRF field is empty. Even if I fill in the username and password, I can never pass validation because the CSRF is required.

I'm not really sure where to look. My sfGuardPlugin configuration is fairly standard, I think. The login page and the CSRF protection generally works fine.

The action I'm using just does $this->form->bind($request->getParameter($this->form->getName()), $request->getFiles($this->form->getName()));

  • 写回答

1条回答 默认 最新

  • doudiao2335 2011-04-28 13:16
    关注

    there're some mistake you may make

    1. processing the form both by get and post. add if($request->isMethod('post')) to handle form submit only by post.
    2. didn't render the hidden field in the template. csrf field is hidden. using echo $form to render the entire form or $form->renderHiddenFields()
    评论

报告相同问题?

悬赏问题

  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大