|
|
|
|
@ -25,8 +25,7 @@ import org.springframework.web.filter.CorsFilter;
|
|
|
|
|
* @author ruoyi
|
|
|
|
|
*/
|
|
|
|
|
@EnableGlobalMethodSecurity(prePostEnabled = true, securedEnabled = true)
|
|
|
|
|
public class SecurityConfig extends WebSecurityConfigurerAdapter
|
|
|
|
|
{
|
|
|
|
|
public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
|
|
|
|
/**
|
|
|
|
|
* 自定义用户认证逻辑
|
|
|
|
|
*/
|
|
|
|
|
@ -68,8 +67,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
|
|
|
|
|
*/
|
|
|
|
|
@Bean
|
|
|
|
|
@Override
|
|
|
|
|
public AuthenticationManager authenticationManagerBean() throws Exception
|
|
|
|
|
{
|
|
|
|
|
public AuthenticationManager authenticationManagerBean() throws Exception {
|
|
|
|
|
return super.authenticationManagerBean();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -89,8 +87,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
|
|
|
|
|
* authenticated | 用户登录后可访问
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
protected void configure(HttpSecurity httpSecurity) throws Exception
|
|
|
|
|
{
|
|
|
|
|
protected void configure(HttpSecurity httpSecurity) throws Exception {
|
|
|
|
|
httpSecurity
|
|
|
|
|
// CSRF禁用,因为不使用session
|
|
|
|
|
.csrf().disable()
|
|
|
|
|
@ -126,8 +123,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
|
|
|
|
|
* 强散列哈希加密实现
|
|
|
|
|
*/
|
|
|
|
|
@Bean
|
|
|
|
|
public BCryptPasswordEncoder bCryptPasswordEncoder()
|
|
|
|
|
{
|
|
|
|
|
public BCryptPasswordEncoder bCryptPasswordEncoder() {
|
|
|
|
|
return new BCryptPasswordEncoder();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -135,8 +131,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
|
|
|
|
|
* 身份认证接口
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
protected void configure(AuthenticationManagerBuilder auth) throws Exception
|
|
|
|
|
{
|
|
|
|
|
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
|
|
|
|
|
auth.userDetailsService(userDetailsService).passwordEncoder(bCryptPasswordEncoder());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|