Skip to content

Commit

Permalink
Add CSP frame-ancestors, make X-Frame-Options conditional (#977)
Browse files Browse the repository at this point in the history
The X-Frame-Options header has been obsoleted by the frame-ancestors
directive. Retain the X-Frame-Options header for older browsers.

Return empty X-Frame-Options header for WordPress Customizer content
to prevent the conflict that SAMEORIGIN would have with the ALLOW-FROM
option that WordPress adds on its own (Safari browser).
Discussion in https://core.trac.wordpress.org/ticket/40020
  • Loading branch information
fullyint authored May 19, 2018
1 parent 12dde2f commit e3315fe
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
### HEAD
* Add CSP `frame-ancestors`, make `X-Frame-Options` conditional ([#977](https://github.com/roots/trellis/pull/977))
* Common: Install `git` instead of `git-core` ([#989](https://github.com/roots/trellis/pull/989))
* Add `xdebug.remote_autostart` to simplify xdebug sessions ([#985](https://github.com/roots/trellis/pull/985))
* Enable nginx to start on boot ([#980](https://github.com/roots/trellis/pull/980))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# The X-Frame-Options header indicates whether a browser should be allowed
# to render a page within a frame or iframe.
add_header X-Frame-Options SAMEORIGIN always;
# add_header X-Frame-Options SAMEORIGIN always;

# MIME type sniffing security protection
# There are very few edge cases where you wouldn't want this enabled.
Expand Down
14 changes: 14 additions & 0 deletions roles/wordpress-setup/templates/wordpress-site.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,20 @@ server {

{% endblock %}

{% block embed_security -%}
{% if item.value.nginx_embed_security | default(nginx_embed_security | default(true)) -%}
add_header Content-Security-Policy "frame-ancestors 'self'" always;

# Conditional X-Frame-Options until https://core.trac.wordpress.org/ticket/40020 is resolved
set $x_frame_options SAMEORIGIN;
if ($arg_customize_changeset_uuid) {
set $x_frame_options "";
}
add_header X-Frame-Options $x_frame_options always;

{% endif -%}
{% endblock -%}

{% block location_php -%}
location ~ \.php$ {
{% block location_php_basic -%}
Expand Down

0 comments on commit e3315fe

Please sign in to comment.