1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/actionview/lib/action_view/helpers
Andrew White 31abee0341 Add support for automatic nonce generation for Rails UJS
Because the UJS library creates a script tag to process responses it
normally requires the script-src attribute of the content security
policy to include 'unsafe-inline'.

To work around this we generate a per-request nonce value that is
embedded in a meta tag in a similar fashion to how CSRF protection
embeds its token in a meta tag. The UJS library can then read the
nonce value and set it on the dynamically generated script tag to
enable it to execute without needing 'unsafe-inline' enabled.

Nonce generation isn't 100% safe - if your script tag is including
user generated content in someway then it may be possible to exploit
an XSS vulnerability which can take advantage of the nonce. It is
however an improvement on a blanket permission for inline scripts.

It is also possible to use the nonce within your own script tags by
using `nonce: true` to set the nonce value on the tag, e.g

    <%= javascript_tag nonce: true do %>
      alert('Hello, World!');
    <% end %>

Fixes #31689.
2018-02-19 15:59:34 +00:00
..
tags Rails 6 requires Ruby 2.3+ 2018-02-17 10:03:37 -08:00
active_model_helper.rb Fix field_error_proc wrap form select optgroup and divider option tag 2017-11-09 17:37:06 +01:00
asset_tag_helper.rb Fix as attribute value for preload link 2018-01-31 13:08:50 +02:00
asset_url_helper.rb Fix typos, update documentation 2018-01-11 17:10:06 -08:00
atom_feed_helper.rb Fix broken doc layout for action_view [ci skip] 2017-08-27 09:12:19 +09:00
cache_helper.rb Use tt in doc for ActionView [ci skip] 2017-08-27 16:08:17 +09:00
capture_helper.rb Use tt in doc for ActionView [ci skip] 2017-08-27 16:08:17 +09:00
controller_helper.rb Fix broken doc layout for action_view [ci skip] 2017-08-27 09:12:19 +09:00
csp_helper.rb Add support for automatic nonce generation for Rails UJS 2018-02-19 15:59:34 +00:00
csrf_helper.rb Fix broken doc layout for action_view [ci skip] 2017-08-27 09:12:19 +09:00
date_helper.rb Enable autocorrect for Lint/EndAlignment cop 2018-01-18 17:19:13 +09:00
debug_helper.rb Fix broken doc layout for action_view [ci skip] 2017-08-27 09:12:19 +09:00
form_helper.rb Fix typo in API document FormHelper#fields 2018-01-25 16:58:32 +09:00
form_options_helper.rb Remove needless blank lines [ci skip] 2017-12-30 16:58:47 +09:00
form_tag_helper.rb Fix output of select_tag with include_blank: true [ci skip] 2017-11-08 16:46:57 +09:00
javascript_helper.rb Add support for automatic nonce generation for Rails UJS 2018-02-19 15:59:34 +00:00
number_helper.rb Use frozen string literal in actionview/ 2017-07-24 11:53:43 +03:00
output_safety_helper.rb Use frozen string literal in actionview/ 2017-07-24 11:53:43 +03:00
record_tag_helper.rb Fix broken doc layout for action_view [ci skip] 2017-08-27 09:12:19 +09:00
rendering_helper.rb Fix broken doc layout for action_view [ci skip] 2017-08-27 09:12:19 +09:00
sanitize_helper.rb Fix broken doc layout for action_view [ci skip] 2017-08-27 09:12:19 +09:00
tag_helper.rb Fix some typos. 2017-10-10 23:08:03 -04:00
tags.rb Fix broken doc layout for action_view [ci skip] 2017-08-27 09:12:19 +09:00
text_helper.rb Fix typos. Improve text_helper documentation. 2018-01-19 17:56:00 -08:00
translation_helper.rb [Action View] require_relative => require 2017-10-21 22:48:28 +09:00
url_helper.rb docs: add example for a nil name in link_to 2017-12-07 01:43:43 +01:00