@Override
protected void configure(HttpSecurity http) throws Exception {
http.headers().contentSecurityPolicy("default-src 'self';" +
"style-src 'self' 'unsafe-inline';" +
"img-src 'self' data: ;" +
"script-src 'self' 'unsafe-inline'")
.and().contentTypeOptions()
.and().xssProtection()
.and().cacheControl()
.and().httpStrictTransportSecurity()
.and().frameOptions();
}
分享给朋友们怎样设置Springboot Content Security Policy 的
本文介绍如何在Spring Boot中配置Content Security Policy (CSP),通过示例代码展示如何设置默认来源、样式来源、图片来源及脚本来源等,增强Web应用的安全性。
2万+

被折叠的 条评论
为什么被折叠?



