alleyinteractive / wp-alleyvate

Defaults for WordPress sites by Alley.
GNU General Public License v2.0
16 stars 2 forks source link

Automatically include X-Frame-Options header on all requests #66

Closed srtfisher closed 6 months ago

srtfisher commented 6 months ago

Description

I would like to see the X-Frame-Options header included on all requests where possible. The header is used to indicate whether a browser should be allowed to render a page in a iframe, frame, embed, or object per the docs here. As a best practice for our clients, we should prevent their site from being able to be embedded into an iframe unless they explicitly allow for it.

Out of the box, the site should send a X-Frame-Options: SAMEORIGIN header (see send_frame_options_header()) on all applicable requests. Optionally, we can also send the Content-Security-Policy: frame-ancestors <source> header, too, which is a stronger header to send but requires an allow list of sources.

The header should also have a short-circuit filter to quickly disable it.

Use Case

When a user tries to put a client site into an iframe, they shouldn't be able to because the X-Frame-Options: SAMEORIGIN header is being sent.