应该<protected-views>用于 JSF 2.2 CSRF 保护? [英] Should <protected-views> be used for JSF 2.2 CSRF protection?

查看:17
本文介绍了应该<protected-views>用于 JSF 2.2 CSRF 保护?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很困惑.我看到 JSF 2.0 具有隐式 CSRF 保护:JSF 2.0 如何防止 CSRF

I am confused. I see that JSF 2.0 has implicit CSRF protection: How JSF 2.0 prevents CSRF

另一边根据文章http://www.oracle.com/webfolder/technetwork/tutorials/obe/java/JSF-CSRF-Demo/JSF2.2CsrfDemo.html 我们应该将以下元素添加到 带有 JSF 页面列表的 faces-config.xml 文件.

On the other side according to the article http://www.oracle.com/webfolder/technetwork/tutorials/obe/java/JSF-CSRF-Demo/JSF2.2CsrfDemo.html we should add the following element to the faces-config.xml file with the list of JSF pages.

<protected-views>
   <url-pattern>/csrf_protected_page.xhtml</url-pattern>
</protected-views>

是否应该将 用于 JSF 2.2 CSRF 保护?

Should <protected-views> be used for JSF 2.2 CSRF protection?

推荐答案

我很困惑.我看到 JSF 2.0 具有隐式 CSRF 保护:JSF 2.0 如何防止 CSRF

此隐式保护仅适用于 POST 请求(即带有 的页面).

This implicit protection is on POST requests only (i.e. pages with <h:form>).

另一边根据文章http://www.oracle.com/webfolder/technetwork/tutorials/obe/java/JSF-CSRF-Demo/JSF2.2CsrfDemo.html 我们应该将以下元素添加到faces-config.xml 包含 JSF 页面列表的文件.

On the other side according to the article http://www.oracle.com/webfolder/technetwork/tutorials/obe/java/JSF-CSRF-Demo/JSF2.2CsrfDemo.html we should add the following element to the faces-config.xml file with the list of JSF pages.

<protected-views>
   <url-pattern>/csrf_protected_page.xhtml</url-pattern>
</protected-views>

这种保护也对 GET 请求有效(即带有 的页面,这也是自 JSF 2.2 以来的新内容).每当您使用 来创建指向这些页面的 GET 链接/按钮时,然后一个新的 GET 请求参数 javax带有自动生成的令牌值的 .faces.Token 将附加到生成的 HTML 输出中的 URL 中,并且当在 .

This protection will also be effective on GET requests (i.e. pages with <f:viewAction>, which is also new since JSF 2.2). Whenever you use <h:link> or <h:button> to create GET links/buttons to those pages, then a new GET request parameter javax.faces.Token with an autogenerated token value will be appended to the URL in the generated HTML output and this parameter would be required when the page in question is declared in <protected-views>.

应该将 用于 JSF 2.2 CSRF 保护吗?

Should <protected-views> be used for JSF 2.2 CSRF protection?

仅在您希望 CSRF 保护的带有 的页面上.那些带有 的已经被 javax.faces.ViewState 隐藏输入字段隐式保护,前提是你没有通过 <f:viewtransient="true">.另见 a.o.JSF 中的 CSRF、XSS 和 SQL 注入攻击预防.

Only on pages with <f:viewAction> which you'd like to CSRF-protect. Those with <h:form> are already implicitly protected by javax.faces.ViewState hidden input field, provided that you didn't turn off JSF view state by <f:view transient="true">. See also a.o. CSRF, XSS and SQL Injection attack prevention in JSF.

这篇关于应该&lt;protected-views&gt;用于 JSF 2.2 CSRF 保护?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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