作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我看spring web site并想防止我的网站表单 xss 和 xframe 攻击
但是我的英语不够好,无法弄清楚要设置什么
请指导我还应该设置什么??
我只是添加一个 WebSecurityConfig.java
下 src/com/test/web/security
这是我的代码:
package com.test.web.security;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
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;
@EnableWebSecurity
@Configuration
@ComponentScan
public class WebSecurityConfig extends
WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http
// ...
.headers();
}
}
最佳答案
如果您只指定与上面相同的代码,Spring Security 应该自动添加所有相关的安全 header 。根据文档:
If you are using Spring Security’s Java configuration, all of the default security headers are added by default.
As soon as you specify any headers that should be included, then only those headers will be include
关于spring-mvc - 如何使用spring security防止xss和xframe攻击,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31282379/
我是一名优秀的程序员,十分优秀!