我已经使用 Spring Security 成功设置了一个应用程序。当用户请求安全页面时,Spring 会自动将这些用户重定向到 HTTPS 页面。
<http auto-config="true" use-expressions="true" once-per-request="true" >
<intercept-url pattern="/login" access="permitAll" requires-channel="https"/>
<intercept-url pattern="/my-account" access="isAuthenticated()" requires-channel="https"/>
<logout />
<form-login login-page="/login" />
<port-mappings>
<port-mapping http="8080" https="8443"/>
<port-mapping http="80" https="443"/>
</port-mappings>
</http>
但是当用户浏览时,接下来其他没有敏感信息的页面仍然使用HTTPS。我希望仅使用 HTTP 访问这些普通页面。
有什么聪明的方法可以做到这一点吗?我没有配置为 HTTPS channel 的所有其他页面我希望仅使用 HTTP 进行访问。我尝试使用一些通配符但没有成功。
额外的细节: HTTPS 使用更多的服务器 CPU。我在某些页面上有很多请求,我想避免这笔额外费用。
最佳答案
将您的整个网站设为 HTTPS。这些天性能变化很小,您不会通过 HTTP 公开他们的 session cookie 来欺骗您的用户。
关于spring - 使用 Spring Security 配置 HTTP 页面和 HTTPS 页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28438254/