我有一个使用弹簧安全保护的应用程序。
简短地讲述这个故事:
许多对不安全资源(如图像或其他资产)的请求都是在https上完成的(来自其他应用程序的一些请求)。 Spring安全设置如下:
<security:intercept-url pattern="/**" requires-channel="http" />
(具体保护其他路径)。
这导致了一个问题,对同一资源网址执行重定向(302响应)但使用http。 应用程序要求资源会制止这种情况。结果是嵌入了https页面不受保护的资源(来自http)。
我认为解决方案是将requires-channel =&#34; any&#34;请记住,这不会执行重定向。
现在的问题是,任何对https的请求都会从spring security重定向到登录页面,而且似乎我在配置文件中找不到任何设置来执行此操作,而且文档中没有任何信息。
有人能帮助我一些想法吗?
<security:http disable-url-rewriting="true">
<security:anonymous username="anonymous" granted-authority="ROLE_ANONYMOUS" />
<!-- session stealing is prevented by using secure GUID cookie -->
<security:session-management session-fixation-protection="none" />
<!-- SSL / AUTHENTICATED pages -->
<security:intercept-url pattern="/my-account*" access="ROLE_CUSTOMERGROUP" requires-channel="https" />
<security:intercept-url pattern="/my-account/**" access="ROLE_CUSTOMERGROUP" requires-channel="https" />
<security:intercept-url pattern="/**" requires-channel="any" /> <!-- Everything else should be insecure -->
<security:form-login
login-page="/login"
authentication-failure-handler-ref="loginAuthenticationFailureHandler"
authentication-success-handler-ref="loginGuidAuthenticationSuccessHandler" />
<security:logout logout-url="/logout" success-handler-ref="logoutSuccessHandler" />
<security:port-mappings>
<security:port-mapping http="#{configurationService.configuration.getProperty('tomcat.http.port')}"
https="#{configurationService.configuration.getProperty('tomcat.ssl.port')}" />
<security:port-mapping http="80" https="443" />
<!--security:port-mapping http="#{configurationService.configuration.getProperty('proxy.http.port')}"
https="#{configurationService.configuration.getProperty('proxy.ssl.port')}" /-->
</security:port-mappings>
<security:request-cache ref="httpSessionRequestCache" />
</security:http>