diff --git a/spring-session/pom.xml b/spring-session/pom.xml
index 42a414afdc..8388efb6c3 100644
--- a/spring-session/pom.xml
+++ b/spring-session/pom.xml
@@ -10,9 +10,9 @@
com.baeldung
- parent-boot-1
+ parent-boot-2
0.0.1-SNAPSHOT
- ../parent-boot-1
+ ../parent-boot-2
diff --git a/spring-session/spring-session-redis/pom.xml b/spring-session/spring-session-redis/pom.xml
index 37402634b0..8d225e06ed 100644
--- a/spring-session/spring-session-redis/pom.xml
+++ b/spring-session/spring-session-redis/pom.xml
@@ -9,9 +9,9 @@
com.baeldung
- parent-boot-1
+ parent-boot-2
0.0.1-SNAPSHOT
- ../../parent-boot-1
+ ../../parent-boot-2
@@ -25,7 +25,7 @@
org.springframework.session
- spring-session
+ spring-session-data-redis
org.springframework.boot
@@ -36,6 +36,11 @@
embedded-redis
${embedded-redis.version}
+
+ redis.clients
+ jedis
+ jar
+
diff --git a/spring-session/spring-session-redis/src/main/java/com/baeldung/spring/session/SecurityConfig.java b/spring-session/spring-session-redis/src/main/java/com/baeldung/spring/session/SecurityConfig.java
index 1da6d9422d..678c98e7eb 100644
--- a/spring-session/spring-session-redis/src/main/java/com/baeldung/spring/session/SecurityConfig.java
+++ b/spring-session/spring-session-redis/src/main/java/com/baeldung/spring/session/SecurityConfig.java
@@ -1,23 +1,31 @@
package com.baeldung.spring.session;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
+import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
+import org.springframework.security.crypto.password.PasswordEncoder;
@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
-
+
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
- auth.inMemoryAuthentication().withUser("admin").password("password").roles("ADMIN");
+ auth.inMemoryAuthentication().withUser("admin").password(passwordEncoder().encode("password")).roles("ADMIN");
}
-
+
@Override
protected void configure(HttpSecurity http) throws Exception {
http.httpBasic().and().authorizeRequests().antMatchers("/").hasRole("ADMIN").anyRequest().authenticated();
}
+
+ @Bean
+ public PasswordEncoder passwordEncoder() {
+ return new BCryptPasswordEncoder();
+ }
}
diff --git a/spring-session/spring-session-redis/src/test/java/com/baeldung/spring/session/SessionControllerIntegrationTest.java b/spring-session/spring-session-redis/src/test/java/com/baeldung/spring/session/SessionControllerIntegrationTest.java
index 7ee0294315..065533c73f 100644
--- a/spring-session/spring-session-redis/src/test/java/com/baeldung/spring/session/SessionControllerIntegrationTest.java
+++ b/spring-session/spring-session-redis/src/test/java/com/baeldung/spring/session/SessionControllerIntegrationTest.java
@@ -5,7 +5,7 @@ import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.springframework.boot.context.embedded.LocalServerPort;
+import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.test.web.client.TestRestTemplate;
diff --git a/spring-social-login/pom.xml b/spring-social-login/pom.xml
index 9fa839f1c2..628f439cc0 100644
--- a/spring-social-login/pom.xml
+++ b/spring-social-login/pom.xml
@@ -8,9 +8,9 @@
com.baeldung
- parent-boot-1
+ parent-boot-2
0.0.1-SNAPSHOT
- ../parent-boot-1
+ ../parent-boot-2
@@ -42,15 +42,16 @@
org.thymeleaf.extras
- thymeleaf-extras-springsecurity4
+ thymeleaf-extras-springsecurity5
org.springframework.social
spring-social-facebook
+ ${spring.social.facebook.version}
-
+
org.springframework.boot
spring-boot-starter-data-jpa
@@ -60,6 +61,12 @@
com.h2database
h2
+
+
+ net.bytebuddy
+ byte-buddy-dep
+ ${bytebuddy.version}
+
@@ -93,5 +100,10 @@
+
+
+ 1.10.9
+ 2.0.3.RELEASE
+
\ No newline at end of file
diff --git a/spring-social-login/src/main/java/com/baeldung/config/Application.java b/spring-social-login/src/main/java/com/baeldung/config/Application.java
index 5d083d2d47..c65df6dbfe 100644
--- a/spring-social-login/src/main/java/com/baeldung/config/Application.java
+++ b/spring-social-login/src/main/java/com/baeldung/config/Application.java
@@ -3,7 +3,7 @@ package com.baeldung.config;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.domain.EntityScan;
-import org.springframework.boot.web.support.SpringBootServletInitializer;
+import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
@SpringBootApplication
diff --git a/spring-social-login/src/main/java/com/baeldung/config/SecurityConfig.java b/spring-social-login/src/main/java/com/baeldung/config/SecurityConfig.java
index 3d3081fef9..152c7b229a 100644
--- a/spring-social-login/src/main/java/com/baeldung/config/SecurityConfig.java
+++ b/spring-social-login/src/main/java/com/baeldung/config/SecurityConfig.java
@@ -1,8 +1,7 @@
package com.baeldung.config;
-import com.baeldung.security.FacebookSignInAdapter;
-import com.baeldung.security.FacebookConnectionSignup;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
@@ -14,22 +13,27 @@ import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.social.connect.ConnectionFactoryLocator;
import org.springframework.social.connect.UsersConnectionRepository;
import org.springframework.social.connect.mem.InMemoryUsersConnectionRepository;
+import org.springframework.social.connect.support.ConnectionFactoryRegistry;
import org.springframework.social.connect.web.ProviderSignInController;
+import org.springframework.social.facebook.connect.FacebookConnectionFactory;
+
+import com.baeldung.security.FacebookConnectionSignup;
+import com.baeldung.security.FacebookSignInAdapter;
@Configuration
@EnableWebSecurity
@ComponentScan(basePackages = { "com.baeldung.security" })
public class SecurityConfig extends WebSecurityConfigurerAdapter {
+
+ @Value("${spring.social.facebook.appSecret}")
+ String appSecret;
+
+ @Value("${spring.social.facebook.appId}")
+ String appId;
@Autowired
private UserDetailsService userDetailsService;
- @Autowired
- private ConnectionFactoryLocator connectionFactoryLocator;
-
- @Autowired
- private UsersConnectionRepository usersConnectionRepository;
-
@Autowired
private FacebookConnectionSignup facebookConnectionSignup;
@@ -55,7 +59,19 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Bean
// @Primary
public ProviderSignInController providerSignInController() {
+ ConnectionFactoryLocator connectionFactoryLocator = connectionFactoryLocator();
+ UsersConnectionRepository usersConnectionRepository = getUsersConnectionRepository(connectionFactoryLocator);
((InMemoryUsersConnectionRepository) usersConnectionRepository).setConnectionSignUp(facebookConnectionSignup);
return new ProviderSignInController(connectionFactoryLocator, usersConnectionRepository, new FacebookSignInAdapter());
}
+
+ private ConnectionFactoryLocator connectionFactoryLocator() {
+ ConnectionFactoryRegistry registry = new ConnectionFactoryRegistry();
+ registry.addConnectionFactory(new FacebookConnectionFactory(appId, appSecret));
+ return registry;
+ }
+
+ private UsersConnectionRepository getUsersConnectionRepository(ConnectionFactoryLocator connectionFactoryLocator) {
+ return new InMemoryUsersConnectionRepository(connectionFactoryLocator);
+ }
}
\ No newline at end of file