我正在使用Spring 3.2 + primefaces 3.5 + hibernate 4.1.9 安全上下文是:
<http auto-config='false' use-expressions="true" >
<intercept-url pattern="/**/login" access="permitAll" requires-channel="https"/>
<intercept-url pattern="/**/registration" access="permitAll" requires-channel="https" />
<intercept-url pattern="/**/cart" access="permitAll" requires-channel="https" />
<intercept-url pattern="/**/cart/**" access="hasAnyRole('USER','ADMIN')" requires-channel="https" />
<intercept-url pattern="/pages/adm/**" access="hasRole('ADMIN')" requires-channel="https" />
<intercept-url pattern="/*/account**" access="hasAnyRole('USER','ADMIN')" requires-channel="https" />
<intercept-url pattern="/**" requires-channel="any" />
<form-login login-page="/loginRedirect"
authentication-failure-handler-ref="pennyUrlAuthenticationFailureHandler"
authentication-success-handler-ref="pennyAuthSuccessHandler"
default-target-url="/pages/account/orders.xhtml" />
<logout logout-success-url="/" invalidate-session="true"/>
</http>
<http auto-config='false' use-expressions="true" >
<intercept-url pattern="/**/login" access="permitAll" requires-channel="https"/>
<intercept-url pattern="/**/registration" access="permitAll" requires-channel="https" />
<intercept-url pattern="/**/cart" access="permitAll" requires-channel="https" />
<intercept-url pattern="/**/cart/**" access="hasAnyRole('USER','ADMIN')" requires-channel="https" />
<intercept-url pattern="/pages/adm/**" access="hasRole('ADMIN')" requires-channel="https" />
<intercept-url pattern="/*/account**" access="hasAnyRole('USER','ADMIN')" requires-channel="https" />
<intercept-url pattern="/**" requires-channel="any" />
<form-login login-page="/loginRedirect"
authentication-failure-handler-ref="pennyUrlAuthenticationFailureHandler"
authentication-success-handler-ref="pennyAuthSuccessHandler"
default-target-url="/pages/account/orders.xhtml" />
<logout logout-success-url="/" invalidate-session="true"/>
</http>
如果我转到需要HTTPS的页面,对于剩余的会话,它将使用HTTPS协议,即使用户未经过身份验证。 如果我转到https:// mystite / en / cart,HTTPS将用于所有浏览会话。
我不想永久地将HTTPS切换到HTTP,但前提是用户未经过身份验证。 我可以强制HTTP用于未经身份验证的用户吗?
答案 0 :(得分:1)
如果我转到需要HTTPS的页面,对于其余的会话,它 将使用HTTPS协议,即使用户未经过身份验证。
这是正确的,因为
<intercept-url pattern="/**/cart/**" access="hasAnyRole('USER','ADMIN')" requires-channel="https" />
另外,因为
<intercept-url pattern="/**" requires-channel="any" />
一旦用户请求了需要HTTPS的资源,它就会坚持使用HTTPS。如果你说any
(HTTPS和任何一样好),为什么还要切换回去?
我可以强制HTTP用于未经身份验证的用户吗?
不,不是我所知道的。就个人而言,我认为这也没有多大意义。