【发布时间】:2020-10-27 07:23:57
【问题描述】:
我正在开发 Java Spring Boot 系统并尝试使用 SAML 单点登录与 Azure 非图库应用程序集成。
我找到了如何创建非图库应用程序,如何将非图库应用程序应用到 Azure 图库列表等。例如,此链接是关于配置 SAML SSO: Configure SAML-based single sign-on 所以我了解了 Azure 端的配置和程序。
我正在使用 Spring Security SAML 扩展。但是,除了基于 XML 的官方 SAML 扩展文档外,我做了很多研究,也找不到 Spring Boot 端配置。
顺便说一下,我的主要目标是将我们的组织应用添加到 Azure 库应用列表。我们的应用被多家公司使用,因此如果我们将组织应用添加到 Azure Gallery App list,我们的客户可以将其 Azure AD 帐户配置为 SSO 集成。
我的问题如下:
- 如何将 Azure Non-Gallery 应用集成到 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 元数据 XML
- 然后客户的 Azure AD SSO 可以集成到我们的系统中
如果有什么不对的地方请指教。
【问题讨论】:
标签: spring-boot spring-security azure-active-directory saml-2.0 spring-saml