Skip to content

Commit

Permalink
Use a base64 hash if a nonce isn't available in the session
Browse files Browse the repository at this point in the history
  • Loading branch information
martinemde committed Feb 1, 2024
1 parent b2ee2b8 commit 02ddaff
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion config/initializers/content_security_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
# Suggested nonce generator doesn't work on first page load https://github.com/rails/rails/issues/48463
# Related PR attempting to fix: https://github.com/rails/rails/pull/48510
request.session.send(:load_for_write!) # force session to be created
request.session.id.to_s.presence || raise("No session ID available in #{request.inspect}")
request.session.id.to_s.presence || SecureRandom.base64(16)
}
Rails.application.config.content_security_policy_nonce_directives = %w[script-src style-src]

Expand Down

0 comments on commit 02ddaff

Please sign in to comment.