这快把我逼疯了。
我使用的是Tomcat6,基于表单的解密身份验证。不涉及任何框架。一切正常-一些页面通过了身份验证,一些没有,一些使用了https,一些使用了http。一切都如我所愿。除了..。
我希望登录页面始终使用https。
如果: a)我在浏览器中直接转到登录页面,登录页面就会很好地显示为https。b)我单击应用程序中为https配置的页面(需要身份验证)。
但是,如果: a)我单击应用程序中为http配置的页面(并且需要身份验证),则登录页面将显示为http。
我有一种感觉,我在这里遇到了某种公认的默认设置,答案可能是“为什么要使用https登录才能访问非https页面?”它是这样的: a)我希望密码是加密的。b)我希望用户登录以显示他们所属的角色(组),以便启用/禁用网站的某些部分。c)除非绝对必要,否则我不希望由于https而导致性能下降。
我猜如果登录页面被强制为https (就像我希望的那样),那么必须有一种机制将其放回http。
如果任何人对这整个领域有一些建议/想法,我会非常非常棒。
web.xml片段:
<security-constraint>
    <display-name>Security Constraint A0S1</display-name>
    <web-resource-collection>
        <web-resource-name>A0S1</web-resource-name>
        <url-pattern>/login/*</url-pattern>
    </web-resource-collection>
    <user-data-constraint>
        <transport-guarantee>CONFIDENTIAL</transport-guarantee>
    </user-data-constraint>    
</security-constraint>
<login-config>
    <auth-method>FORM</auth-method>
    <form-login-config>
        <form-login-page>/login/form_login.jsp</form-login-page>
        <form-error-page>/login/error.jsp</form-error-page>
    </form-login-config>
</login-config>发布于 2010-06-27 17:44:18
这是为了确保登录页面是https,即使需要身份验证的页面在web.xml中没有设置为机密。
我最终编写了一个小servlet,允许我切换到https (或http),而不是依赖于web.xml机密配置设置。当您通过登录或通过另一个servlet到达jsp页面时,机密设置似乎不起作用。
因此,现在登录中的表单身份验证的配置指向一个servlet (SSLSwitch),该servlet接受两个参数(url +所需的协议http/https),并使用https: / /SSLSwitch?the_url=/login/form_login.jsp&the_target=https;/ web.xml /SSLSwitch重定向到实际的登录页面
SSLSwitch Servlet活动代码片段: String contextPath = request.getContextPath();String encodedUrl = response.encodeURL(contextPath + url);String fullUrl = target_domain + encodedUrl;response.sendRedirect(fullUrl);
jsp登录页面本身遵循通常的表单登录规则(action="j_security_check"),在登录ok之后,您将到达请求的页面。
我现在需要看看在从https切换到http之后,我可以做些什么来提高会话安全性。也许检查用户IP的筛选器在会话期间不会改变。
史蒂文。
https://stackoverflow.com/questions/3124697
复制相似问题