Skip to content

Commit bd824ce

Browse files
committed
Fix countdown CSP.
1 parent 0849974 commit bd824ce

File tree

6 files changed

+23
-4
lines changed

6 files changed

+23
-4
lines changed

Diff for: app.rb

+7-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,13 @@
1818
get "/live" do
1919
content_type :html
2020
SecureHeaders.use_secure_headers_override(request, :live)
21-
send_file File.join(settings.public_folder, 'live.html')
21+
send_file File.join(settings.public_folder, "live.html")
22+
end
23+
24+
get "/countdown" do
25+
content_type :html
26+
SecureHeaders.use_secure_headers_override(request, :countdown)
27+
send_file File.join(settings.public_folder, "countdown.html")
2228
end
2329

2430
get "/go" do

Diff for: config/application.rb

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
configure do
1212
use Rack::SslEnforcer, only_hosts: (ENV["SSL_ENFORCER_HOST"] || /\.herokuapp\.com$/)
1313
use SecureHeaders::Middleware
14+
set :protection, :except => [:frame_options] # Disable things that secure_headers handles
1415
set :erb, trim: "-"
1516
# Look up Rack::Mime::MIME_TYPES to see rack defaults
1617
mime_type :opensearch, "application/opensearchdescription+xml"

Diff for: config/initializers/10-secure_headers.rb

+13-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@
5757
end
5858
end
5959

60-
# Live page
6160
SecureHeaders::Configuration.override(:live) do |config|
6261
config.csp.merge!({
6362
# "meta" values. these will shape the header, but the values are not included in the header.
@@ -72,3 +71,16 @@
7271
connect_src: %w(graph.facebook.com www.googleapis.com api.twitch.tv),
7372
})
7473
end
74+
75+
SecureHeaders::Configuration.override(:countdown) do |config|
76+
config.x_frame_options = SecureHeaders::OPT_OUT
77+
config.csp.merge!({
78+
# "meta" values. these will shape the header, but the values are not included in the header.
79+
report_only: false,
80+
preserve_schemes: true,
81+
# directive values: these values will directly translate into source directives
82+
default_src: %w('none'),
83+
style_src: %w('unsafe-inline'),
84+
script_src: %w('unsafe-inline'),
85+
})
86+
end

Diff for: public/countdown.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
}
3030

3131
function init() {
32-
// Parse query string, e.g: countdown.html?date=2018-09-27T03:30:00Z
32+
// Parse query string, e.g: /countdown?date=2018-09-27T03:30:00Z
3333
var params = {};
3434
window.location.search.substr(1).split("&").forEach(function(param) {
3535
param = param.split("=");

Diff for: public/img/icon512.png

127 KB
Loading

Diff for: views/youtube_feed.erb

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
title += " (scheduled for #{updated.readable(@tz)})"
2828
content_extra = <<~EOF
2929
<p>Live broadcast scheduled to start at: #{updated.readable(@tz)}.</p>
30-
<iframe width="640" height="50" src="#{request.root_url}/countdown.html?date=#{updated}" frameborder="0" scrolling="yes" referrerpolicy="no-referrer"></iframe>
30+
<iframe width="640" height="50" src="#{request.root_url}/countdown?date=#{updated}" frameborder="0" scrolling="yes" referrerpolicy="no-referrer"></iframe>
3131
EOF
3232
end
3333
end

0 commit comments

Comments
 (0)