Spring SAML:除了使用/ saml / metadata端点外,还可以使用其他方法来生成SP元数据

时间:2019-05-01 17:04:47

标签: spring spring-security saml saml-2.0 spring-saml

背景:我的网络应用正在PROD中运行,并且实际用户正在使用它。初始身份验证是使用Spring Basic Security实现的。

最近,客户端决定使用SSO进行身份验证,因此我的应用应与客户端IdP一起充当SP。我使用Spring SAML将我的应用程序配置为SP。

在质量检查环境中与客户端IDP集成涉及以下步骤:

  1. 获取并存储从客户那里收到的IdP元数据文件。
  2. 在环境上使用SP配置部署代码。
  3. 使用/saml/metadata端点生成SP元数据文件,并与客户共享。
  4. 在正确的位置从客户IdP处获得该SP元数据文件的绿灯。
  5. 验证SSO是否正常工作。

现在,是时候在PROD环境上部署SP SSO配置并将其与客户端PROD IdP集成了。

我不喜欢将以上方法用于PROD,因为在生成应用程序SP元数据文件并将其放置在客户IDP的正确位置之前,实际用户将无法登录该应用程序。

谁能告诉我在PROD上部署SSO配置之前如何为我的应用程序预先生成SP元数据文件?

2 个答案:

答案 0 :(得分:1)

(1)引用“最近,客户端决定使用SSO进行身份验证,因此我的应用程序应与客户端IDP一起用作SP。我使用Spring SAML将我的应用程序配置为SP。”

响应

我想您使用the official GitHub repository of Spring Security SAML提供的Spring SAML来“将您的应用配置为SP”。

(2)引用“在QA环境中与客户端IdP集成涉及以下步骤:..”

响应

关于将Web应用程序作为SP与客户端IdP集成的五(5)个步骤(由您的帖子提供)是“在PROD环境中部署SP SSO配置并将其与客户端PROD IdP集成”的实用SAML标准。

通过提供我对另一个最近的Stackoverflow问题“ I have provided an instruction to address another Stackoverflow How can I generate metadata file of my Java Spring Application to establish a connection with Identity Provider like Ping Federate?”的回答,我分享了将Web应用程序作为SAML SP与SAML IdP集成的实践经验。

(3)引用“我不喜欢将以上方法用于PROD,因为在生成应用程序SP元数据文件并将其放置在客户的正确位置之前,实际用户将无法登录到该应用程序IdP。”

响应

如果您“不喜欢将以上方法用于PROD”,则可以修改“ spring-security-saml / samples / boot / simple-service-provider /”的源代码(由{{3 }}),将您的网络应用配置为SAML SP。

(4)问题“谁能告诉我在PROD上部署SSO配置之前,如何预先为我的应用生成SP元数据文件?”

答案

(I)关于“如何运行身份提供商(IDP)和服务提供商(SP)的简单示例”的自述文件(由the official GitHub repository of Spring Security SAML提供)将指导您“如何生成SP元数据文件在PROD上部署SSO配置之前,先为我的应用准备。”

(II)我着重介绍了“在PROD上部署SSO配置之前,如何为我的Web应用程序预先生成Spring Basic Security的SAML SP元数据文件”的相关信息。

第2步-启动服务提供商

服务提供商在the official GitHub repository of Spring Security SAML上运行

$git clone https://github.com/spring-projects/spring-security-saml

$cd spring-security-saml

$./gradlew :spring-security-saml-samples/boot/simple-service-provider:bootRun &

(II.a)启动Web浏览器以访问URL http://localhost:8080/sample-sp 确保Spring Security SAML服务提供程序运行良好。

(II.b)启动Web浏览器以访问SP元数据终结点
http://localhost:8080/sample-sp
在“在PROD上部署SSO配置之前,”先下载或“为我的应用预先生成SP元数据文件”。

(5)问题“ Spring SAML:除了使用/ saml / metadata端点之外,还可以生成SP元数据的替代方法”

答案

您可以修改源代码“ spring-security-saml / samples / boot / simple-service-provider / src / main / java / sample / config / SecurityConfiguration.java”(由http://localhost:8080/sample-sp/saml/sp/metadata提供) “除了使用/ saml / sp / metadata端点之外,还生成SP元数据”。

例如,如果要从特定端点(例如/ example / metadata)生成SP元数据,则只需替换
“ super(” / saml / sp /“,beanConfig);”
(在下面显示的源代码中)与
“ super(” / example /“,beanConfig);”

        public SamlSecurity(BeanConfig beanConfig, @Qualifier("appConfig") AppConfig appConfig) {
            super("/saml/sp/", beanConfig);
            this.appConfig = appConfig;
}

答案 1 :(得分:0)

只要您知道端点的URI和签名证书,就可以手动生成它们并在配置中指定它们。