parent
1297458c60
commit
f1d0456ec5
@ -1,10 +1,18 @@
|
|||||||
server:
|
server:
|
||||||
port: 9090
|
port: 9090
|
||||||
|
|
||||||
camel:
|
camel:
|
||||||
springboot:
|
springboot:
|
||||||
main-run-controller: true
|
main-run-controller: true
|
||||||
|
|
||||||
spring:
|
spring:
|
||||||
activemq:
|
activemq:
|
||||||
broker-url: "tcp://localhost:61616"
|
broker-url: "tcp://localhost:61616"
|
||||||
|
ldap:
|
||||||
|
urls: ldap://localhost:10389
|
||||||
|
base: dc=vidconnect,dc=cyou
|
||||||
|
username: cn=admin,dc=vidconnect,dc=cyou
|
||||||
|
password: xxx
|
||||||
|
|
||||||
app:
|
app:
|
||||||
queue-name: "UserServiceQueue"
|
queue-name: "UserServiceQueue"
|
@ -1,15 +0,0 @@
|
|||||||
package com.example.camel;
|
|
||||||
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.jakarta.rs.json.JacksonJsonProvider;
|
|
||||||
|
|
||||||
@Configuration
|
|
||||||
public class CxfConfig {
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public JacksonJsonProvider jaxrsProvider() {
|
|
||||||
return new JacksonJsonProvider();
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,61 @@
|
|||||||
|
package com.example.camel;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.ldap.core.support.BaseLdapPathContextSource;
|
||||||
|
import org.springframework.security.authentication.AuthenticationManager;
|
||||||
|
import org.springframework.security.config.Customizer;
|
||||||
|
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||||
|
import org.springframework.security.config.ldap.LdapBindAuthenticationManagerFactory;
|
||||||
|
import org.springframework.security.ldap.userdetails.DefaultLdapAuthoritiesPopulator;
|
||||||
|
import org.springframework.security.ldap.userdetails.LdapAuthoritiesPopulator;
|
||||||
|
import org.springframework.security.web.SecurityFilterChain;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.jakarta.rs.json.JacksonJsonProvider;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class SecurityConfig {
|
||||||
|
|
||||||
|
@Value("${app.group-search-base:ou=groups}")
|
||||||
|
private String groupSearchBase;
|
||||||
|
|
||||||
|
@Value("${app.group-search-filter:(member={0})}")
|
||||||
|
private String groupSearchFilter;
|
||||||
|
|
||||||
|
@Value("${app.user-search-base:ou=people}")
|
||||||
|
private String userSearchBase;
|
||||||
|
|
||||||
|
@Value("${app.user-search-filter:(uid={0})}")
|
||||||
|
private String userSearchFilter;
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
|
||||||
|
http.authorizeHttpRequests((authorize) -> authorize.anyRequest().fullyAuthenticated())
|
||||||
|
.httpBasic(Customizer.withDefaults());
|
||||||
|
|
||||||
|
return http.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public LdapAuthoritiesPopulator authorities(BaseLdapPathContextSource contextSource) {
|
||||||
|
DefaultLdapAuthoritiesPopulator authorities = new DefaultLdapAuthoritiesPopulator(contextSource,
|
||||||
|
groupSearchBase);
|
||||||
|
authorities.setGroupSearchFilter(groupSearchFilter);
|
||||||
|
return authorities;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public AuthenticationManager authenticationManager(BaseLdapPathContextSource contextSource,
|
||||||
|
LdapAuthoritiesPopulator authorities) {
|
||||||
|
LdapBindAuthenticationManagerFactory factory = new LdapBindAuthenticationManagerFactory(contextSource);
|
||||||
|
factory.setUserSearchBase(userSearchBase);
|
||||||
|
factory.setUserSearchFilter(userSearchFilter);
|
||||||
|
return factory.createAuthenticationManager();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public JacksonJsonProvider jaxrsProvider() {
|
||||||
|
return new JacksonJsonProvider();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue