Skip to content

Commit c7b4d16

Browse files
BE: Fix double LDAP bean init (#220)
Co-authored-by: Roman Zabaluev <gpg@haarolean.dev>
1 parent 1d318cb commit c7b4d16

File tree

2 files changed

+5
-11
lines changed

2 files changed

+5
-11
lines changed

api/src/main/java/io/kafbat/ui/KafkaUiApplication.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import org.springframework.scheduling.annotation.EnableAsync;
99
import org.springframework.scheduling.annotation.EnableScheduling;
1010

11-
@SpringBootApplication(exclude = LdapAutoConfiguration.class)
11+
@SpringBootApplication
1212
@EnableScheduling
1313
@EnableAsync
1414
public class KafkaUiApplication {

api/src/main/java/io/kafbat/ui/config/auth/LdapSecurityConfig.java

+4-10
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,10 @@
1010
import lombok.RequiredArgsConstructor;
1111
import lombok.extern.slf4j.Slf4j;
1212
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
13-
import org.springframework.boot.autoconfigure.ldap.LdapAutoConfiguration;
1413
import org.springframework.boot.context.properties.EnableConfigurationProperties;
1514
import org.springframework.context.ApplicationContext;
1615
import org.springframework.context.annotation.Bean;
1716
import org.springframework.context.annotation.Configuration;
18-
import org.springframework.context.annotation.Import;
19-
import org.springframework.context.annotation.Primary;
2017
import org.springframework.ldap.core.DirContextOperations;
2118
import org.springframework.ldap.core.support.BaseLdapPathContextSource;
2219
import org.springframework.ldap.core.support.LdapContextSource;
@@ -43,7 +40,6 @@
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

Comments
 (0)