Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Spring Security X-frame拒绝_Java_Spring_Spring Security - Fatal编程技术网

Java Spring Security X-frame拒绝

Java Spring Security X-frame拒绝,java,spring,spring-security,Java,Spring,Spring Security,我使用的是Easy UI+Spring Security+Spring Boot 在我向项目中添加OAuth2设置并重新生成网页之后 Refused to display 'http://localhost:8080/vehicle/admin/index' in a frame because it set 'X-Frame-Options' to 'DENY'. 我知道这是因为Spring安全框架选项 但是我试着将选项设置为SAMEORIGIN还是DISABLE,但仍然不起作用 My we

我使用的是Easy UI+Spring Security+Spring Boot

在我向项目中添加OAuth2设置并重新生成网页之后

Refused to display 'http://localhost:8080/vehicle/admin/index' in a frame because it set 'X-Frame-Options' to 'DENY'.
我知道这是因为Spring安全框架选项

但是我试着将选项设置为SAMEORIGIN还是DISABLE,但仍然不起作用

My webSecurityAdapter方法配置为:

@Override
protected void configure(HttpSecurity http) throws Exception {
    http
    .headers().frameOptions().sameOrigin().and()
    .csrf().disable()
    .anonymous().disable()
    .authorizeRequests()
    .antMatchers("/oauth/token").permitAll();
}
更新:

尝试了多个http配置,但仍然不起作用

代码


@但这就是为什么我感到困惑,它仍然是否定的,而不是相同的。我尝试了不同的设置,但得到了相同的结果result@dur是的,我肯定。我已经在使用/oauth/token来获取访问令牌,并且api URL受到spring安全框架的保护。暂时我只是使用WebConfigure忽略安全过滤器中的url,它可以正常工作
@Configuration
    @Order(1)
    public class TokenWebConfiguration extends WebSecurityConfigurerAdapter{
     @Autowired
        private CustomAuthenticationProvider authProvider;

        @Autowired
        private ClientDetailsService clientDetailsService;

        @Autowired
        public void globalUserDetails(AuthenticationManagerBuilder auth) throws Exception {
            auth.authenticationProvider(authProvider);
        }

        @Override
        protected void configure(HttpSecurity http) throws Exception {
            http
            .csrf().disable()
            .anonymous().disable()
            .authorizeRequests()
            .antMatchers("/oauth/token").permitAll();
        }
}


@Configuration
    @Order(2)
    public class CommonWebConfiguration extends WebSecurityConfigurerAdapter{
         @Override
            protected void configure(HttpSecurity http) throws Exception {
                http
                .antMatcher("/admin/**")
                .headers().frameOptions().sameOrigin();
            }
    }