我使用的是jsf 2+ jaas + ssl + tomcat 6.0.26
我的网站中有两条路径:
/faces/protected/*,它使用SSL
/faces/unprotected/*,它不使用SSL。
我在我的web.xml里放了这个:
<login-config>
<auth-method>FORM</auth-method>
<form-login-config>
<form-login-page>/faces/login.jsp</form-login-page>
<form-error-page>/faces/error.jsp</form-error-page>
</form-login-config>
</login-config>
<security-constraint>
<web-resource-collection>
<web-resource-name>Secure Resource</web-resource-name>
<description/>
<url-pattern>/faces/unprotected/*</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
<http-method>HEAD</http-method>
<http-method>PUT</http-method>
<http-method>OPTIONS</http-method>
<http-method>TRACE</http-method>
<http-method>DELETE</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>C</role-name>
</auth-constraint>
</security-constraint>
<security-constraint>
<web-resource-collection>
<web-resource-name>Secure Resource</web-resource-name>
<description />
<url-pattern>/faces/protected/*</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
<http-method>HEAD</http-method>
<http-method>PUT</http-method>
<http-method>OPTIONS</http-method>
<http-method>TRACE</http-method>
<http-method>DELETE</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>C</role-name>
</auth-constraint>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>
<security-role>
<description> Role Client </description>
<role-name>C</role-name>
</security-role>这是我的server.xml:
<Connector port="8080" protocol="HTTP/1.1"
maxThreads="400"
maxKeepAliveRequests="1"
acceptCount="100"
connectionTimeout="3000"
redirectPort="8443"
compression="on"
compressionMinSize="2048"
noCompressionUserAgents="gozilla, traviata"
compressableMimeType="text/javascript,text/css,text/html, text/xml,text/plain,application/x-javascript,application/javascript,application/xhtml+xml" />
<Connector port="8443" protocol="org.apache.coyote.http11.Http11AprProtocol" SSLEnabled="true"
maxThreads="400" scheme="https" secure="true"
clientAuth="optional" sslProtocol="TLS"
SSLCertificateFile="path/to/crt"
SSLCertificateKeyFile="path/to/pem"/>当我进入受保护路径时,它会切换到HTTPS (端口8443),但当我进入路径/faces/ protected /somthing...它仍然使用HTTPS。
我想要的是,当我进入未受保护的路径时,它会恢复到非SSL通信(否则,当我在浏览器中设置确切的地址时,我必须重新登录)。
我的配置有什么问题?
有没有办法让我可以做这样的事情?
是否可以使用调用页面而不要求第二次身份验证?
发布于 2010-12-27 21:01:38
是的,这是Tomcat上的正常行为。
一旦移动到https中,它就不会将其他URL重定向回http,除非该URL显式用于http。
如果确实需要,则必须编写一个Filter来检查该URL是否不是安全模式的一部分,然后重定向回http。
发布于 2012-05-03 23:46:12
如果您在HTTPS下登录,然后移回HTTP,则会将经过身份验证的cookie暴露给中间人攻击。这很糟糕。
在对会话进行身份验证的整个过程中,您应该一直使用HTTPS。
与你的应用程序所做的工作相比,执行SSL所需的计算是微不足道的。只要坚持使用SSL即可。
https://stackoverflow.com/questions/4537550
复制相似问题