在 Jetty 7 中将 JSESSIONID cookie 设置为 httpOnly

2024-04-05

我们正在运行 grails 2.0 + jetty 7.6.6 并且需要将 JSESSIONID cookie 设置为 httpOnly。 stackoverflow 上的所有答案似乎都涉及 Servlet 3.0(需要 jetty 8)或 tomcat。 任何人都可以为我提供一种将 JSESSIONID cookie 设置为 jetty 7.x 的 httpOnly 的明确方法吗?

我尝试添加包含以下内容的 jetty-web.xml 文件,但它仍然不起作用(即 JSESSIONID 未标记为 httpOnly):

<?xml version="1.0"  encoding="ISO-8859-1"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">

<Configure class="org.eclipse.jetty.webapp.WebAppContext">
    <Get name="sessionHandler">
        <Get name="sessionManager">
            <Set name="httpOnly" type="boolean">true</Set>
        </Get>
    </Get>
</Configure>

我所要做的就是将 jetty-web.xml 放在正确的文件夹中。最初我投入的是jetty/etc文件夹,但它应该位于WEB-INF目录。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

在 Jetty 7 中将 JSESSIONID cookie 设置为 httpOnly 的相关文章

随机推荐