How to use spring security to prevent xss and xframe attack

前端 未结 2 908
有刺的猬
有刺的猬 2021-01-06 12:39

I look spring web site and want to prevent my website form xss and xframe attack

But My english is not well enough to figure out what to set

Please guide

2条回答
  •  感动是毒
    2021-01-06 13:37

    Please use following code for example

    @Override
        protected void configure(HttpSecurity http) throws Exception {
            http.authorizeRequests().antMatchers("/api/**").hasAnyRole("ADMIN","USER").and().httpBasic().and().headers().disable();
            //.and().formLogin();
    
    
        }
    

提交回复
热议问题