spring-boot - 将 Spring Boot Security SAML 与 Azure AD Gallery 应用程序集成为多租户
问题描述
我正在开发 Java Spring Boot 系统并尝试使用 SAML 单点登录与 Azure 非图库应用程序集成。
我找到了如何创建非图库应用程序,如何将非图库应用程序应用到 Azure 图库列表等。例如,此链接是关于配置 SAML SSO: 配置基于 SAML 的单点登录 所以我了解了 Azure 端的配置和程序。
我正在使用 Spring Security SAML 扩展。但是,除了基于 XML 的官方 SAML 扩展文档外,即使我做了很多研究,我也找不到 Spring Boot 端配置。
顺便说一句,我的主要目标是将我们的组织应用程序添加到 Azure 库应用程序列表。我们的应用被多家公司使用,因此如果我们将组织应用添加到 Azure Gallery 应用列表,我们的客户可以将其 Azure AD 帐户配置为 SSO 集成。
我的问题如下:
- 如何将 Azure 非图库应用程序集成到 Spring Boot 应用程序?
- 如何处理多个 Azure AD 租户?
有人帮我解决这个问题吗?
编辑: 目前我使用 Spring Boot 和 Azure AD 非图库应用程序进行了单租户 SSO 登录。我使用 Azure AD 联合 XML 元数据 URL 配置了 IdP 元数据。您可以在下面查看源代码:
@Configuration
@Order(1)
public static class ApiWebSecurityConfigurationAdapter extends WebSecurityConfigurerAdapter {
@Value("${security.saml2.metadata-url}")
private String IdPMetadataURL;
@Value("${server.ssl.key-alias}")
private String keyStoreAlias;
@Value("${server.ssl.key-store-password}")
private String keyStorePassword;
@Value("${server.port}")
String port;
@Value("${server.ssl.key-store}")
private String keyStoreFile;
@Autowired
private SAMLUserService samlUserService;
@Override
protected void configure(final HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers("/saml/**", "/", "/login", "/home", "/about").permitAll()
.anyRequest().authenticated()
.and()
.apply(saml())
.webSSOProfileConsumer(getWebSSOProfileConsumerImpl())
.userDetailsService(samlUserService)
.serviceProvider()
.keyStore()
.storeFilePath(this.keyStoreFile)
.password(this.keyStorePassword)
.keyname(this.keyStoreAlias)
.keyPassword(this.keyStorePassword)
.and()
.protocol("https")
.hostname(String.format("%s:%s", "localhost", this.port))
.basePath("/")
.and()
.identityProvider()
.metadataFilePath(IdPMetadataURL)
.and();
}
public WebSSOProfileConsumerImpl getWebSSOProfileConsumerImpl(){
WebSSOProfileConsumerImpl consumer = new WebSSOProfileConsumerImpl();
consumer.setMaxAuthenticationAge(26000000); //300 days
return consumer;
}
}
从现在开始,我需要生成 IdP 元数据 XML,而不是使用 IdP 元数据 URL。使用以下字段:
- IdP 实体 ID
- IdP SSO URL
- IdP 公共证书
我正在考虑的过程是:
- 我们的客户在上面注册了他们的 Azure AD IdP 字段
- 我的 Spring Boot 系统自动生成 IdP Metadata XML
- 然后客户的 Azure AD SSO 可以集成到我们的系统中
如果有什么不妥请教教我。
解决方案
我在 Spring Boot 中使用 Spring Security SAML 扩展。您使用哪个 SAML IdP 无关紧要,因为您只需要 IdP 元数据。您生成您的 SP 元数据并按照 MS 文档中的说明使用它。您可以查看 Spring Security SAML 文档。
推荐阅读
- postgresql - 出现致命错误:运行 pgAdmin4 时无法联系服务器。“NoneType”对象没有属性“值”
- javascript - Javascript 仅在输入字段中允许退格和数字
- c# - 如何使用 ForEach 显示 List 中的每个剩余元素
- sql - where 子句和 group by 中的别名
- performance - 整数除法主要用于什么?
- geoserver - GeoServer 2.19.0 和 Tomcat 10 有问题吗?(错误 404)
- javascript - 如何在.js文件中加载html元素
- c++ - C++ proto2“表达式不可分配”错误
- bash - 从文件中提取日期并格式化它们
- python - 尝试在不使用 API 的情况下自动化 Instagram 照片上传过程