【发布时间】:2019-04-21 12:48:23
【问题描述】:
我正在尝试使用 Okta 对来自 SpringBoot 应用程序的用户进行身份验证。
我已经按照 Okta 教程设置了应用程序:https://developer.okta.com/blog/2017/03/16/spring-boot-saml
但是,我的应用程序位于 ELB 之后,因此 TLS 在 LB 处终止。所以我修改了教程中的配置以满足我的需要。
@Override
protected void configure(final HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers("/saml*").permitAll()
.anyRequest().authenticated()
.and()
.apply(saml())
.serviceProvider()
.keyStore()
.storeFilePath(this.keyStoreFilePath)
.password(this.password)
.keyname(this.keyAlias)
.keyPassword(this.password)
.and()
.protocol("https")
.hostname(String.format("%s", serverName))
.basePath("/")
.and()
.identityProvider()
.metadataFilePath(this.metadataUrl);
}
这可以解决问题,但有一个问题。用户通过 Okta 身份验证后,最终将用户重定向到 http URL 而不是 https URL。我认为这样做的原因是 TLS 在 LB 处被终止,而我的应用实际上正在接收带有 http 的请求,该请求是在 RelayState 中发送的。
这是我发现的:spring-boot-security-saml-config-options.md。 它包含 Spring Boot 安全性的 SAML 属性列表。我在 application.properties 文件中添加了以下内容
saml.sso.context-provider.lb.enabled = true
saml.sso.context-provider.lb.scheme=https
saml.sso.profile-options.relay-state=<https://my.website.com>
它不会改变 http 重定向。是不是我做错了什么?
【问题讨论】:
标签: spring-boot saml-2.0 spring-saml okta