首页 > 解决方案 > 如何从 Spring Security 5 中检索 SAML SP 元数据

问题描述

我正在使用Spring Security Core 5 中的 SAML 功能集(不是Spring Security SAML extension,它已过时)。到目前为止,我可以毫无问题地调出示例并登录到IdP ,即使它在我的本地主机中。但是,我想提取我的 SP 元数据以提供给我的 IdP。当我访问 SP 元数据 URL ( http://localhost:8080/saml2/service-provider-metadata/simplesamlphp) 时,示例将我重定向到 IdP 登录页面。似乎所有路径都受到保护。我使用 WebSecurityConfigurerAdapter 进行了自定义,但是当我访问 SP 元数据 URL 时,它返回 404。

什么是正确的 SP 元数据 URL?如何找回它?

@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
    
    @Override
    protected void configure(HttpSecurity http) throws Exception {
        
        http.authorizeRequests()
            .antMatchers("/saml2/service-provider-metadata/**")
            .permitAll()
            .anyRequest().authenticated()
            .and()
            .saml2Login();
        
    }
}

2020 年 6 月 26 日更新

Spring Security Github中的代码搜索结果SPSSODescriptor为空,但Spring Security SAML 扩展 Github中没有。是否有设置没有元数据的 SAML SP 的新方法?

标签: spring-securitysamlsaml-2.0spring-saml

解决方案


这是因为 Spring Security 团队还没有在 Spring Security v5.3 及以下版本中实现 SAML 2.0 SP Metadata Endpoint。有关详细信息,请参见此处此处

更新: 它已在2020 年 8 月 6 日之后实施


推荐阅读