Skip to content

Commit 514c053

Browse files
committed
Review fixes: Make bind authenticator nullable for the AD case
1 parent ad1c65e commit 514c053

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import java.util.Optional;
99
import lombok.RequiredArgsConstructor;
1010
import lombok.extern.slf4j.Slf4j;
11+
import org.springframework.beans.factory.annotation.Autowired;
1112
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
1213
import org.springframework.boot.context.properties.EnableConfigurationProperties;
1314
import org.springframework.context.ApplicationContext;
@@ -53,14 +54,14 @@ public ReactiveAuthenticationManager authenticationManager(AbstractLdapAuthentic
5354

5455
@Bean
5556
public AbstractLdapAuthenticationProvider authenticationProvider(LdapAuthoritiesPopulator authoritiesExtractor,
56-
BindAuthenticator bindAuthenticator,
57+
@Autowired(required = false) BindAuthenticator ba,
5758
AccessControlService acs) {
5859
var rbacEnabled = acs.isRbacEnabled();
5960

6061
AbstractLdapAuthenticationProvider authProvider;
6162

6263
if (!props.isActiveDirectory()) {
63-
authProvider = new LdapAuthenticationProvider(bindAuthenticator, authoritiesExtractor);
64+
authProvider = new LdapAuthenticationProvider(ba, authoritiesExtractor);
6465
} else {
6566
authProvider = new ActiveDirectoryLdapAuthenticationProvider(props.getActiveDirectoryDomain(),
6667
props.getUrls());
@@ -76,6 +77,7 @@ public AbstractLdapAuthenticationProvider authenticationProvider(LdapAuthorities
7677
}
7778

7879
@Bean
80+
@ConditionalOnProperty(value = "oauth2.ldap.activeDirectory", havingValue = "false")
7981
public BindAuthenticator ldapBindAuthentication(LdapContextSource ldapContextSource) {
8082
BindAuthenticator ba = new BindAuthenticator(ldapContextSource);
8183

0 commit comments

Comments
 (0)