【发布时间】:2023-03-19 17:46:01
【问题描述】:
我有以下 java 过滤器来让 CSP 对我的 Angular 应用程序的每个响应进行处理。
public class FrameOptionsFilter implements Filter {
@Override
public void doFilter(ServletRequest request, ServletResponse servletResponse, final FilterChain filterChain)
throws IOException, ServletException {
HttpServletResponse response = (HttpServletResponse) servletResponse;
response.setHeader("Content-Security-Policy", "frame-ancestors 'none'");
...
我使用这个 sn-p 来测试我的应用程序:
<html>
<head>
<title>Clickjacking Test</title>
</head>
<body>
<p>Website is vulnerable to clickjacking!</p>
<iframe src="http://localhost:4200/myapp/" width="600" height="600"></iframe>
</body>
</html>
登录屏幕加载,一旦我登录,我仍然可以访问应用程序!
来自服务器的响应:
Request URL: https://localhost:4200/myapp/login/jwt
HTTP/1.1 200 OK
X-Powered-By: Servlet/3.1
Content-Security-Policy: frame-ancestors 'none'
我错过了什么?
【问题讨论】:
标签: iframe content-security-policy x-frame-options