Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@
import static org.apache.wicket.csp.CSPDirective.CONNECT_SRC;
import static org.apache.wicket.csp.CSPDirective.DEFAULT_SRC;
import static org.apache.wicket.csp.CSPDirective.FONT_SRC;
import static org.apache.wicket.csp.CSPDirective.FRAME_ANCESTORS;
import static org.apache.wicket.csp.CSPDirective.IMG_SRC;
import static org.apache.wicket.csp.CSPDirective.MANIFEST_SRC;
import static org.apache.wicket.csp.CSPDirective.OBJECT_SRC;
import static org.apache.wicket.csp.CSPDirective.REPORT_URI;
import static org.apache.wicket.csp.CSPDirective.SCRIPT_SRC;
import static org.apache.wicket.csp.CSPDirective.STYLE_SRC;
Expand Down Expand Up @@ -131,6 +133,17 @@ public CSPHeaderConfiguration strict()
.add(BASE_URI, SELF);
}

/**
* Hardens the CSP configuration by adding {@code frame-ancestors 'self'} to prevent embedding
* (clickjacking) and {@code object-src 'none'} to disable plugin execution.
*
* @return {@code this} for chaining.
*/
public CSPHeaderConfiguration enableStrictEmbeddingProtection()
{
return add(FRAME_ANCESTORS, SELF).add(OBJECT_SRC, NONE);
}

/**
* Configures the CSP to report violations back at the application.
*
Expand Down