upgrade to boot 2

This commit is contained in:
Loredana Crusoveanu 2018-06-09 10:36:09 +03:00
parent 5836bfa794
commit 625ae33681
2 changed files with 11 additions and 4 deletions

View File

@ -10,10 +10,10 @@
<description>Spring Security with Thymeleaf tutorial</description>
<parent>
<artifactId>parent-boot-5</artifactId>
<artifactId>parent-boot-2</artifactId>
<groupId>com.baeldung</groupId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../parent-boot-5</relativePath>
<relativePath>../parent-boot-2</relativePath>
</parent>
<dependencies>

View File

@ -1,11 +1,13 @@
package com.baeldung.springsecuritythymeleaf;
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.web.util.matcher.AntPathRequestMatcher;
@Configuration
@ -33,11 +35,16 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
auth.inMemoryAuthentication()
.withUser("user")
.password("password")
.password(passwordEncoder().encode("password"))
.roles("USER")
.and()
.withUser("admin")
.password("admin")
.password(passwordEncoder().encode("admin"))
.roles("ADMIN");
}
@Bean
public BCryptPasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder();
}
}