use*_*364 5 spring-mvc spring-security
我看spring网站 ,想防止我的网站表单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();
}
}
Run Code Online (Sandbox Code Playgroud)
如果您只指定与上面相同的代码,Spring Security 应该自动添加所有相关的安全标头。根据文档:
\n\n\n\n\n如果您使用 Spring Security\xe2\x80\x99s Java 配置,则默认情况下会添加所有\n 默认安全标头。
\n
还:
\n\n\n\n\n一旦您指定了应包含的任何标头,则仅\n将包含这些标头
\n
请参阅本节中的详细信息和代码示例:
\n\n\n 归档时间: |
|
查看次数: |
22413 次 |
最近记录: |