spring boot in a frame because it set ‘X-Frame-Options‘ to ‘deny‘

The iframe cannot be loaded in the spring boot security project.

solve:

@Override
    protected void configure(HttpSecurity http) throws Exception {
       
        //  允许所有用户访问"/"和"/index.html"
        http.authorizeRequests()
                .antMatchers("/js/**").permitAll()
                .anyRequest().authenticated()   // 其他地址的访问均需验证权限
                .and()
                .formLogin()
                .loginPage("/login")   //  登录页
                .defaultSuccessUrl("/index")
                .usernameParameter("username")
                .passwordParameter("password")
                .and()
                .headers().frameOptions().disable()// 不加报 in a frame because it set 'X-Frame-Options' to 'deny'.
                .and().csrf().disable(); // TODO spring security的跨域保护(CSRF Protection) CSRF是指跨站请求伪造(Cross-site request forgery),是web常见的攻击之一。
    }

 

Guess you like

Origin blog.csdn.net/csl12919/article/details/113094953