自定义的`RelyingPartyRegistrationRepository`实现

huangapple go评论115阅读模式
英文:

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.

huangapple
  • 本文由 发表于 2020年10月26日 05:03:18
  • 转载请务必保留本文链接:https://go.coder-hub.com/64528761.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定