【发布时间】:2016-06-21 18:04:02
【问题描述】:
为 SAMLContextProviderLB bean 附加了我的上下文提供程序
**<property name="scheme" value="https"/>**
<property name="serverName" value="${sp.hostname}"/>
<property name="serverPort" value="#{'${sp.ssl.port}'=='' ? 443 : '${sp.ssl.port}'}"/>
<property name="includeServerPortInRequestURL" value="#{'${sp.ssl.port}'=='443' ? false : true }"/>
<property name="contextPath" value="/${sp.context.root}"/>
我在反向代理后面,所以我正在卸载 SSL 终止。后端服务器本身正在侦听非 SSL,但 webtier 正在为我们终止 SSL 并转发到非 SSL 端口。我已经使用上述属性设置了 SAMLContextProviderLB,因此即使后端是 https,它也会知道将 saml 令牌的预期接收者映射为 https 受众。然而,我在下面的日志中看到的是,当我访问受保护的资源时,它会在浏览器上返回垃圾。当我在浏览器中将其更改为 https 时,它会按预期工作。看到下面的日志表明从 DefaultSavedRequest url 返回的值是 HTTP,而它应该是 HTTPs。
2016-03-07 18:24:11,907 信息 org.springframework.security.saml.log.SAMLDefaultLogger.log:127 - AuthNResponse;SUCCESS;10.4.203.88;https://myserver:89/fct;https://www.myADFS.com/adfs/services/trust;camachof@email.com;;
2016-03-07 18:24:11,909 调试 org.springframework.security.saml.SAMLProcessingFilter.successfulAuthentication:317 - 身份验证成功。更新 SecurityContextHolder 以包含:org.springframework.security.providers.ExpiringUsernameAuthenticationToken@830e9237:主体:camachof@email.com;凭证:[受保护];已认证:真实;详细信息:空;未授予任何权限
2016-03-07 18:24:11,910 调试 org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler.onAuthenticationSuccess:79 - 重定向到 DefaultSavedRequest 网址:http ://myserver:89/fct/page
2016-03-07 18:24:11,911 调试 org.springframework.security.web.DefaultRedirectStrategy.sendRedirect:36 - 重定向到“http://myserver:89/fct/page”
2016-03-07 18:24:11,911 调试 org.springframework.security.web.context.HttpSessionSecurityContextRepository.saveContext:292 - SecurityContext 存储到 HttpSession: 'org.springframework.security.core.context.SecurityContextImpl@830e9237:身份验证:org.springframework.security.providers.ExpiringUsernameAuthenticationToken@830e9237:主体:camachof@email.com;凭证:[受保护];已认证:真实;详细信息:空;未授予任何权限
2016-03-07 18:24:11,912 调试 org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter:97 - SecurityContextHolder 现在清除,请求处理完成
任何想法如何在此设置下将其强制为 HTTPS?提前致谢。
【问题讨论】:
标签: java ssl spring-security reverse-proxy spring-saml