|
|
|
@ -1,19 +1,17 @@ |
|
|
|
|
package cc.bnblogs.springinit.config; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import org.springframework.context.annotation.Bean; |
|
|
|
|
import org.springframework.context.annotation.Configuration; |
|
|
|
|
import org.springframework.security.config.annotation.web.builders.HttpSecurity; |
|
|
|
|
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; |
|
|
|
|
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; |
|
|
|
|
import org.springframework.security.crypto.password.PasswordEncoder; |
|
|
|
|
import org.springframework.security.web.SecurityFilterChain; |
|
|
|
|
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@EnableWebSecurity |
|
|
|
|
public class SecurityConfig { |
|
|
|
|
@Configuration |
|
|
|
|
public class SecurityConfig extends WebSecurityConfigurerAdapter { |
|
|
|
|
|
|
|
|
|
@Bean |
|
|
|
|
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception { |
|
|
|
|
@Override |
|
|
|
|
protected void configure(HttpSecurity http) throws Exception { |
|
|
|
|
http |
|
|
|
|
.csrf().disable() |
|
|
|
|
.authorizeRequests() |
|
|
|
@ -26,12 +24,5 @@ public class SecurityConfig { |
|
|
|
|
.and() |
|
|
|
|
.logout() |
|
|
|
|
.permitAll(); |
|
|
|
|
|
|
|
|
|
return http.build(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Bean |
|
|
|
|
public PasswordEncoder passwordEncoder() { |
|
|
|
|
return new BCryptPasswordEncoder(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|