问题:vue前端请求SpringSecuriry权限框架资源返回403没有权限
解决:springSecurity配置类配置所有的资源都可以放行。
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;
@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// auth.inMemoryAuthentication().withUser("admin").password("123456").authorities("PRODUCT_ADD");
}
/**
* 自定义配置
*/
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests().antMatchers("/**").permitAll()// 所有请求都可以访问
.and().csrf().disable() // 跨域請求关闭
.headers().frameOptions().disable(); // 资源下载权限关闭
}
}
发现只能访问最开始的请求,需要把跨站检查关闭。发现可以请求了。