10
10
import lombok .RequiredArgsConstructor ;
11
11
import lombok .extern .slf4j .Slf4j ;
12
12
import org .springframework .boot .autoconfigure .condition .ConditionalOnProperty ;
13
- import org .springframework .boot .autoconfigure .ldap .LdapAutoConfiguration ;
14
13
import org .springframework .boot .context .properties .EnableConfigurationProperties ;
15
14
import org .springframework .context .ApplicationContext ;
16
15
import org .springframework .context .annotation .Bean ;
17
16
import org .springframework .context .annotation .Configuration ;
18
- import org .springframework .context .annotation .Import ;
19
- import org .springframework .context .annotation .Primary ;
20
17
import org .springframework .ldap .core .DirContextOperations ;
21
18
import org .springframework .ldap .core .support .BaseLdapPathContextSource ;
22
19
import org .springframework .ldap .core .support .LdapContextSource ;
43
40
@ Configuration
44
41
@ EnableWebFluxSecurity
45
42
@ ConditionalOnProperty (value = "auth.type" , havingValue = "LDAP" )
46
- @ Import (LdapAutoConfiguration .class )
47
43
@ EnableConfigurationProperties (LdapProperties .class )
48
44
@ RequiredArgsConstructor
49
45
@ Slf4j
@@ -52,18 +48,18 @@ public class LdapSecurityConfig {
52
48
private final LdapProperties props ;
53
49
54
50
@ Bean
55
- public ReactiveAuthenticationManager authenticationManager (BaseLdapPathContextSource contextSource ,
51
+ public ReactiveAuthenticationManager authenticationManager (LdapContextSource ldapContextSource ,
56
52
LdapAuthoritiesPopulator authoritiesExtractor ,
57
53
AccessControlService acs ) {
58
54
var rbacEnabled = acs .isRbacEnabled ();
59
- BindAuthenticator ba = new BindAuthenticator (contextSource );
55
+ BindAuthenticator ba = new BindAuthenticator (ldapContextSource );
60
56
if (props .getBase () != null ) {
61
57
ba .setUserDnPatterns (new String [] {props .getBase ()});
62
58
}
63
59
if (props .getUserFilterSearchFilter () != null ) {
64
60
LdapUserSearch userSearch =
65
61
new FilterBasedLdapUserSearch (props .getUserFilterSearchBase (), props .getUserFilterSearchFilter (),
66
- contextSource );
62
+ ldapContextSource );
67
63
ba .setUserSearch (userSearch );
68
64
}
69
65
@@ -88,8 +84,7 @@ public ReactiveAuthenticationManager authenticationManager(BaseLdapPathContextSo
88
84
}
89
85
90
86
@ Bean
91
- @ Primary
92
- public BaseLdapPathContextSource contextSource () {
87
+ public LdapContextSource ldapContextSource () {
93
88
LdapContextSource ctx = new LdapContextSource ();
94
89
ctx .setUrl (props .getUrls ());
95
90
ctx .setUserDn (props .getAdminUser ());
@@ -99,7 +94,6 @@ public BaseLdapPathContextSource contextSource() {
99
94
}
100
95
101
96
@ Bean
102
- @ Primary
103
97
public DefaultLdapAuthoritiesPopulator ldapAuthoritiesExtractor (ApplicationContext context ,
104
98
BaseLdapPathContextSource contextSource ,
105
99
AccessControlService acs ) {
0 commit comments