Custom `RelyingPartyRegistrationRepository` implementation

2k views Asked by At

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

There are 1 answers

0
s7vr On BEST ANSWER

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.