英文:
Custom `RelyingPartyRegistrationRepository` implementation
问题
似乎Spring始终使用InMemoryRelyingPartyRegistrationRepository
来返回一个类型化的RelyingPartyRegistrationRepository
bean,请参考https://github.com/spring-projects/spring-boot/blob/master/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/saml2/Saml2RelyingPartyRegistrationConfiguration.java。
问题:我如何注入(自动装配)我的自己的RelyingPartyRegistrationRepository
实现?假设我想允许自动装配的依赖方仓库在某个特定客户的SAML配置更新后自动从数据库重新加载。这可行吗?
英文:
It looks like Spring always uses InMemoryRelyingPartyRegistrationRepository
to return a RelyingPartyRegistrationRepository
typed bean, refer to https://github.com/spring-projects/spring-boot/blob/master/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/saml2/Saml2RelyingPartyRegistrationConfiguration.java.
Question: how can I inject (autowire) my own implementation of RelyingPartyRegistrationRepository
? Say I would like to allow the auto wired relying party repository auto reload from database once I have SAML configuration for a certain customer updated. Is this doable?
答案1
得分: 4
可以提供自己的 bean,Spring Boot 自动配置将会被禁用。
@Configuration
@EnableConfigurationProperties(Saml2RelyingPartyProperties.class)
public class SamlConfig{
@Bean
RelyingPartyRegistrationRepository relyingPartyRegistrationRepository(Saml2RelyingPartyProperties properties) {
// 根据需要提供自定义的存储库实现
}
}
在根据需要创建自己的 bean 后,您可能需要进行其他更改。
英文:
You can provide your own bean and spring boot auto configuration will back off.
@Configuration
@EnableConfigurationProperties(Saml2RelyingPartyProperties.class)
public class SamlConfig{
@Bean
RelyingPartyRegistrationRepository relyingPartyRegistrationRepository(Saml2RelyingPartyProperties properties) {
-- Provide custom repository implementation
}
}
You may need other changes after you create your own bean based on what you need.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论