diff --git a/conf/logback.xml b/conf/logback.xml
index 8ddf4a7..c6b6017 100644
--- a/conf/logback.xml
+++ b/conf/logback.xml
@@ -19,6 +19,7 @@
%-5level %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %logger{36} - %msg%n
+
diff --git a/conf/springboot.yml b/conf/springboot.yml
index 1fea45b..7c7b276 100644
--- a/conf/springboot.yml
+++ b/conf/springboot.yml
@@ -1,10 +1,18 @@
server:
port: 9090
+
camel:
springboot:
main-run-controller: true
+
spring:
activemq:
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:
- queue-name: "UserServiceQueue"
\ No newline at end of file
+ queue-name: "UserServiceQueue"
diff --git a/pom.xml b/pom.xml
index d7ece2d..7d08dd7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
4.0.0
com.example
camel-springboot-activemq6-example
- 1.0.1
+ 2.0.0
camel-springboot-activemq6-example
org.springframework.boot
@@ -44,6 +44,18 @@
org.springframework.boot
spring-boot-starter-web
+
+ org.springframework.boot
+ spring-boot-starter-security
+
+
+ org.springframework.ldap
+ spring-ldap-core
+
+
+ org.springframework.security
+ spring-security-ldap
+
org.apache.camel.springboot
diff --git a/src/main/java/com/example/camel/CxfConfig.java b/src/main/java/com/example/camel/CxfConfig.java
deleted file mode 100644
index 6970ced..0000000
--- a/src/main/java/com/example/camel/CxfConfig.java
+++ /dev/null
@@ -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();
- }
-}
\ No newline at end of file
diff --git a/src/main/java/com/example/camel/SecurityConfig.java b/src/main/java/com/example/camel/SecurityConfig.java
new file mode 100644
index 0000000..c8af130
--- /dev/null
+++ b/src/main/java/com/example/camel/SecurityConfig.java
@@ -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();
+ }
+}
\ No newline at end of file