本文介绍了当使用安全通道时,如何获取jetty使用secure-flag发送jsessionid-cookies的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在生产环境中使用Tomcat,在测试环境中使用jetty(通过jetty-maven-plugin)。

I am using Tomcat in my production environment and jetty in my testing environment (via jetty-maven-plugin).

Tomcat在jsessionid -cookie,当它是通过安全通道(https)sendig它看起来像一个好主意,因为它阻止会话暴露,当用户点击。但是码头不是这样!

Tomcat sets the secure-flag on a jsessionid-cookie, when it is sendig it over a secure channel (https), which looks like a good idea to me, becaus it prevents the session from being exposed, when the user klicks on a http://-link. But Jetty does not so!

我想强制Jetty的行为像Tomcat,并且总是设置jsessionid-cookies上的安全标志通过安全通道发送,因为否则,我的测试环境表现相当diffrent然后我的生产环境。但我找不到任何配置选项achive this。

I would like to force Jetty to behave like Tomcat and always set the secure-flag on jsessionid-cookies send over a secure channel, because otherwise, my testing environment behaves considerably diffrent then my production environment. But I cannot find any configuration option to achive this.

我也想知道,如果这是一个安全bug在Jetty。因为如果用户切换回不安全的频道,则不会将通过安全通道发送的jsessionid-cookie标记为安全的会显示安全会话。

I am also wondering, if this is a security-bug in Jetty. Because not marking a jsessionid-cookie send over a secure channel as secure reveals the secure session if the user switches back to an unsecure channel.

推荐答案

在WEB-INF / jetty-web.xml中加入以下内容

Put the following in WEB-INF/jetty-web.xml

<?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="secureCookies" type="boolean">true</Set>
        </Get>
    </Get>
</Configure>

这篇关于当使用安全通道时,如何获取jetty使用secure-flag发送jsessionid-cookies的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-19 16:43