I need to prevent clickjacking attacks in jetty, i tried the following code in web.xml but it doesn't work.
in web.xml
<filter>
<filter-name>HeaderFilter</filter-name>
<filter-class>org.eclipse.jetty.servlets.HeaderFilter</filter-class>
<init-param>
<param-name>headerConfig</param-name>
<param-value>X-Frame-Options: SAMEORIGIN
</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>HeaderFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
What does the
<filter-mapping>for that<filter>look like in yourweb.xml?I would expect something like ...
The partial configuration in your question will result in matching responses that go through your webapp to have the following response headers.
Not sure how that applies to your question about click-jacking though.
Are you sure you want
X-Frame-Options: DENYand not something more sane likeX-Frame-Options: sameorigin?What about the response header
Content-Security-Policy? See if you need that header, with something likeContent-Security-Policy: frame-ancestors 'self';perhaps?What about having a strict
SameSitesetting for your Cookies?