避免在URLS中使用CSRF令牌 [英] Avoid CSRF token in URLS

查看:57
本文介绍了避免在URLS中使用CSRF令牌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在浏览器中,我可以避免看到URL中的CSRF令牌.

In the browser I can see CSRF token in URL which I want to avoid.

http://localhost:8080/......./new?someval = val& CSRFToken = 1975f761-fb40-4146-ad02-29ba9d5b3cdd

根本原因是我们将FORM标记与http方法GET一起使用.用作我们要传递给控制器​​进行某些处理的一些隐藏参数.

The root cause is we are using FORM tag with http method GET. This is being used as some hidden parameters we want to pass to controller for some processing.

如何避免在URL中使用CSRF令牌.因为我不想删除已经测试过的表单,所以会对测试产生影响.

How to avoid CSRF token in URL. Because I dont want to remove form as it is already tested and will be a testing impact.

推荐答案

我遇到了同样的问题,并且更改了提交表单的提交方法

I had the same issue and I changed the submission's method of the form to post

<form action="" method="post">
  <input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/>
  <!-- other tag -->
</form>

这篇关于避免在URLS中使用CSRF令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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