OKTA SAML SSO 与 Spring Security 的集成遇到了很多麻烦。我们正在使用saml-dsl
Spring Security 的扩展来配置身份验证,并且在 HTTP 上一切正常,但是当我们尝试使用 HTTPS 时,身份验证仅在应用程序部署在根 ( /
) 上下文中时才有效。当我们将上下文更改为其他任何内容时,它会停止工作并开始抛出InResponseTo
字段错误,有时使用不同的配置会导致重定向循环。
这是我们正在使用的配置:
http
.csrf()
.disable();
http
.sessionManagement().sessionFixation().none();
http
.logout()
.logoutSuccessUrl("/");
http
.authorizeRequests()
.antMatchers("/saml*").permitAll()
.anyRequest().authenticated()
.and()
.apply(samlConfigurer())
.serviceProvider()
.keyStore()
.storeFilePath(config.getKeystorePath())
.password(config.getKeystorePassword())
.keyname(config.getKeyAlias())
.keyPassword(config.getKeystorePassword())
.and()
.protocol("https")
.hostname(String.format("%s:%s", serverURL, config.getServerPort()))
.basePath("/"+contextRoot)
.and()
.identityProvider()
.metadataFilePath(config.getMetadataUrl());
我们也应该正确设置 OKTA(https://localhost:8443/ourappcontext/saml/SSO 用于测试,所有其他的东西也一样)
我们已经尝试了这里提出的大多数解决方案和 Spring 文档(空工厂、spring 会话管理和会话固定等),但似乎没有任何效果。我们做错了什么吗?我们目前没有生成任何 SP 元数据,这可能是错误的,并且请求以某种方式重定向到错误的地方或其他什么?到目前为止真的很困惑,第一次使用 SAML,我不确定它是扩展、OKTA 配置还是 Spring 配置......
我们在 Wildfly 上进行部署,您可以通过单独的 jboss-web.xml 在其中设置应用程序上下文,如果这很重要的话。