Commit 0bec70c8 authored by 杨伊博's avatar 杨伊博

no message

parent a46fcef8
...@@ -35,11 +35,6 @@ ...@@ -35,11 +35,6 @@
<artifactId>spring-boot-starter-thymeleaf</artifactId> <artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency> </dependency>
<!-- 用于home.html文件中的 hasRole('ROLE_ADMIN') 语句-->
<dependency>
<groupId>org.thymeleaf.extras</groupId>
<artifactId>thymeleaf-extras-springsecurity4</artifactId>
</dependency>
<!--db--> <!--db-->
<dependency> <dependency>
<groupId>mysql</groupId> <groupId>mysql</groupId>
......
...@@ -11,26 +11,27 @@ import org.springframework.security.config.annotation.method.configuration.Enabl ...@@ -11,26 +11,27 @@ import org.springframework.security.config.annotation.method.configuration.Enabl
import org.springframework.security.config.annotation.web.builders.HttpSecurity; 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.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.config.annotation.web.servlet.configuration.EnableWebMvcSecurity;
import org.springframework.security.core.userdetails.UserDetailsService; import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
/** /**
* Created by yangyibo on 17/1/18. * Created by yangyibo on 17/1/18.
*/ */
@Configuration @Configuration
@EnableWebSecurity @EnableWebSecurity
@EnableGlobalMethodSecurity(securedEnabled = true) //@EnableGlobalMethodSecurity(securedEnabled = true)
public class WebSecurityConfig extends WebSecurityConfigurerAdapter { public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Bean @Autowired
UserDetailsService customUserService(){ //注册UserDetailsService 的bean private CustomUserService customUserService;
return new CustomUserService();
}
@Override
@Autowired
protected void configure(AuthenticationManagerBuilder auth) throws Exception { protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.userDetailsService(customUserService()).passwordEncoder(new PasswordEncoder(){ auth.userDetailsService(customUserService).passwordEncoder(new PasswordEncoder(){
@Override @Override
public String encode(CharSequence rawPassword) { public String encode(CharSequence rawPassword) {
...@@ -48,9 +49,6 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter { ...@@ -48,9 +49,6 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
http http
.csrf().disable() .csrf().disable()
.authorizeRequests() .authorizeRequests()
.antMatchers("/login").permitAll()
.antMatchers("/logout").permitAll()
.antMatchers("/").permitAll()
.antMatchers("/users/**") .antMatchers("/users/**")
.authenticated() .authenticated()
.antMatchers(HttpMethod.POST) .antMatchers(HttpMethod.POST)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment