spring - 使用 Spring Security 配置 HTTP 页面和 HTTPS 页面

标签 spring ssl spring-security

我已经使用 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 来欺骗您的用户。

https://istlsfastyet.com/

关于spring - 使用 Spring Security 配置 HTTP 页面和 HTTPS 页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28438254/

相关文章:

java - Spring Security OAuth2 舞蹈和获取参数

java - 检查经过身份验证的用户是否可以访问 URL

spring - 如何在 Hibernate 中将 CLOB 数据类型转换为字符串?

java - 使用 JUnit 测试具有 @PreAuthorize 的服务方法

java - 在 Eclipse 中将 Spring Boot 应用程序导出为 JAR 文件

php - 如何重定向到(或强制执行)SSL 连接?

c# - 将 TCP StreamReader/StreamWriter 转换为 SSLStream

mysql - 使用 Hibernate native 查询插入不适用于 java.util.Date

html - 我的网站安全吗?它安装了 SSL 证书,但地址栏上没有锁定

database - 使用 Spring 3 和 Hibernate 3 的身份验证(基于注释)