在登录表单上禁用CSRF令牌 [英] Disable CSRF token on login form

查看:327
本文介绍了在登录表单上禁用CSRF令牌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Symfony2.0和FOSUserBundle,并且想在我的登录表单上禁用csrf令牌.

I am using Symfony2.0 and FOSUserBundle, and would like to disable the csrf token on my login form.

我已在我的config.yml中的网站上全局禁用了csrf保护:

I have disabled the csrf protection globally on my website in my config.yml:

framework:
    csrf_protection:
        enabled:        false

这工作正常,没有在我的表单中添加csrf字段. 但是,这不适用于登录表单.仅在此表单上,如果我在表单中未包含以下标记,则会收到无效的CSRF令牌"错误:

This is working well, there is no csrf field added to my forms. However, this does not apply to the login form. On this form only, I get an "Invalid CSRF Token" error if I don't include the token in the form with:

<input type="hidden" name="_csrf_token" value="{{ csrf_token }}" />

如何在登录表单上禁用CSRF令牌?

How can I disable the CSRF token on the login form?

推荐答案

如果只是转到security.yml文件并从form_login指令中删除csrf_provider,则无需更新操作类或其他任何内容.

If you just go to your security.yml file and remove the csrf_provider from the form_login directive, don't need to update the action class or anything.

这篇关于在登录表单上禁用CSRF令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆