BAEL-1489: Upgrading to Spring Boot 2 GA and using UserBuilder

This commit is contained in:
Holger Steinhauer 2018-03-30 18:56:40 +01:00
parent 6549e41afa
commit bed25cd0da
2 changed files with 91 additions and 91 deletions

View File

@ -12,8 +12,8 @@
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId> <artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.0.RC2</version> <version>2.0.0.RELEASE</version>
<relativePath /> <!-- lookup parent from repository --> <relativePath/> <!-- lookup parent from repository -->
</parent> </parent>
<dependencies> <dependencies>

View File

@ -14,14 +14,12 @@ import org.springframework.security.crypto.password.StandardPasswordEncoder;
import org.springframework.security.crypto.scrypt.SCryptPasswordEncoder; import org.springframework.security.crypto.scrypt.SCryptPasswordEncoder;
import org.springframework.security.provisioning.InMemoryUserDetailsManager; import org.springframework.security.provisioning.InMemoryUserDetailsManager;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@Configuration @Configuration
public class PasswordStorageWebSecurityConfigurer extends WebSecurityConfigurerAdapter { public class PasswordStorageWebSecurityConfigurer extends WebSecurityConfigurerAdapter {
@Override @Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception { protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.eraseCredentials(false) // 4 auth.eraseCredentials(false) // 4
@ -31,8 +29,10 @@ public class PasswordStorageWebSecurityConfigurer extends WebSecurityConfigurerA
@Bean @Bean
public UserDetailsService getUserDefaultDetailsService() { public UserDetailsService getUserDefaultDetailsService() {
User testUser = new User("baeldung", "{noop}SpringSecurity5", Collections.emptyList()); return new InMemoryUserDetailsManager(User
return new InMemoryUserDetailsManager(testUser); .withUsername("baeldung")
.password("{noop}SpringSecurity5")
.build());
} }
@Bean @Bean