1010import lombok .RequiredArgsConstructor ;
1111import lombok .extern .slf4j .Slf4j ;
1212import org .springframework .boot .autoconfigure .condition .ConditionalOnProperty ;
13- import org .springframework .boot .autoconfigure .ldap .LdapAutoConfiguration ;
1413import org .springframework .boot .context .properties .EnableConfigurationProperties ;
1514import org .springframework .context .ApplicationContext ;
1615import org .springframework .context .annotation .Bean ;
1716import org .springframework .context .annotation .Configuration ;
18- import org .springframework .context .annotation .Import ;
19- import org .springframework .context .annotation .Primary ;
2017import org .springframework .ldap .core .DirContextOperations ;
2118import org .springframework .ldap .core .support .BaseLdapPathContextSource ;
2219import org .springframework .ldap .core .support .LdapContextSource ;
4340@ Configuration
4441@ EnableWebFluxSecurity
4542@ ConditionalOnProperty (value = "auth.type" , havingValue = "LDAP" )
46- @ Import (LdapAutoConfiguration .class )
4743@ EnableConfigurationProperties (LdapProperties .class )
4844@ RequiredArgsConstructor
4945@ Slf4j
@@ -52,18 +48,18 @@ public class LdapSecurityConfig {
5248 private final LdapProperties props ;
5349
5450 @ Bean
55- public ReactiveAuthenticationManager authenticationManager (BaseLdapPathContextSource contextSource ,
51+ public ReactiveAuthenticationManager authenticationManager (LdapContextSource ldapContextSource ,
5652 LdapAuthoritiesPopulator authoritiesExtractor ,
5753 AccessControlService acs ) {
5854 var rbacEnabled = acs .isRbacEnabled ();
59- BindAuthenticator ba = new BindAuthenticator (contextSource );
55+ BindAuthenticator ba = new BindAuthenticator (ldapContextSource );
6056 if (props .getBase () != null ) {
6157 ba .setUserDnPatterns (new String [] {props .getBase ()});
6258 }
6359 if (props .getUserFilterSearchFilter () != null ) {
6460 LdapUserSearch userSearch =
6561 new FilterBasedLdapUserSearch (props .getUserFilterSearchBase (), props .getUserFilterSearchFilter (),
66- contextSource );
62+ ldapContextSource );
6763 ba .setUserSearch (userSearch );
6864 }
6965
@@ -88,8 +84,7 @@ public ReactiveAuthenticationManager authenticationManager(BaseLdapPathContextSo
8884 }
8985
9086 @ Bean
91- @ Primary
92- public BaseLdapPathContextSource contextSource () {
87+ public LdapContextSource ldapContextSource () {
9388 LdapContextSource ctx = new LdapContextSource ();
9489 ctx .setUrl (props .getUrls ());
9590 ctx .setUserDn (props .getAdminUser ());
@@ -99,7 +94,6 @@ public BaseLdapPathContextSource contextSource() {
9994 }
10095
10196 @ Bean
102- @ Primary
10397 public DefaultLdapAuthoritiesPopulator ldapAuthoritiesExtractor (ApplicationContext context ,
10498 BaseLdapPathContextSource contextSource ,
10599 AccessControlService acs ) {
0 commit comments