Commit Graph

833 Commits

Author SHA1 Message Date
Genadi Samokovarov
d25fba89d4 Introduce ActionDispatch::DebugExceptions interceptors
Plugins interacting with the exceptions caught and displayed by
ActionDispatch::DebugExceptions currently have to monkey patch it to get
the much needed exception for their calculation.

With DebugExceptions.register_interceptor, plugin authors can hook into
DebugExceptions and process the exception, before being rendered. They
can store it into the request and process it on the way back of the
middleware chain execution or act on it straight in the interceptor.

The interceptors can be play blocks, procs, lambdas or any object that
responds to `#call`.
2018-04-20 14:55:37 +03:00
Rafael Mendonça França
7a9098fa15
Revert "Merge pull request #32652 from bogdanvlviv/add-missing-changelog-for-32593"
This reverts commit 78ff47f3e77925f72d98579da6feb68f36052ad8, reversing
changes made to daffe03308bffc43ea343a886aab33082d83bb9c.

That changelog entry should only be on 5-2-stable
2018-04-19 23:07:53 -04:00
bogdanvlviv
888dda875b
Add missing changelog entry
https://github.com/rails/rails/pull/32593 was backported to
`5-2-stable` but since 5.2.0 is released the changelog entry should
be in Rails 6.0.0 too.

[ci skip]
2018-04-20 01:50:30 +03:00
bogdanvlviv
698332cf85
Fix reference to fixed issue in actionpack/CHANGELOG.md
Pull Request #32602 fixes Issue #32597.

[ci skip]
2018-04-19 11:50:09 +03:00
Andrew White
0d70e3900d
Don't link issue number in CHANGELOG [ci skip] 2018-04-18 07:18:00 -04:00
Andrew White
35970cbf3f
Pass nonce to CSP policy from outside 2018-04-18 10:51:02 +03:00
Andrey Novikov
b9b660728f
Output only one nonce in CSP header per request 2018-04-17 12:56:26 +03:00
Kevin Deisz
f22bc41a92
Include default headers by default in API mode
ActionDispatch's default headers are now moved into their own module that are by default included in both Base and API. This allows API-mode applications to take advantage of the default security headers, as well as providing an easy way to add more.
2018-04-06 15:13:28 -04:00
bogdanvlviv
15331a2ac4
Add changelog entry for #32446
In #32446 was added method `dig` to `session`.
Improve docs of method `dig`.

[ci skip]
2018-04-06 16:50:38 +03:00
Derek Prior
4701a50b58
Deprecate controller level force_ssl
Today there are two common ways for Rails developers to force their
applications to communicate over HTTPS:

* `config.force_ssl` is a setting in environment configurations that
  enables the `ActionDispatch::SSL` middleware. With this middleware
  enabled, all HTTP communication to your application will be redirected
  to HTTPS. The middleware also takes care of other best practices by
  setting HSTS headers, upgrading all cookies to secure only, etc.
* The `force_ssl` controller method redirects HTTP requests to certain
  controllers to HTTPS.

As a consultant, I've seen many applications with misconfigured HTTPS
setups due to developers adding `force_ssl` to `ApplicationController`
and not enabling `config.force_ssl`. With this configuration, many
application requests can be served over HTTP such as assets, requests
that hit mounted engines, etc. In addition, because cookies are not
upgraded to secure only in this configuration and HSTS headers are not
set, it's possible for cookies that are meant to be secure to be sent
over HTTP.

The confusion between these two methods of forcing HTTPS is compounded
by the fact that they share an identical name. This makes finding
documentation on the "right" method confusing.

HTTPS throughout is quickly becomming table stakes for all web sites.
Sites are expected to operate over HTTPS for all communication,
sensitive or otherwise. Let's encourage use of the broader-reaching
`ActionDispatch::SSL` middleware and elminate this source of user
confusion. If, for some reason, applications need to expose certain
endpoints over HTTP they can do so by properly configuring
`config.ssl_options`.
2018-03-30 09:58:28 -04:00
Rafael Mendonça França
81843bcf65
Don't need to include in the changelog something that was release in 5.2
[ci skip]
2018-03-15 17:32:20 -04:00
Catherine Khuu
46ae2b18ea Check exclude before flagging cookies as secure in ActionDispatch::SSL (#32262)
* Check exclude before flagging cookies as secure.

* Update comments in ActionDispatch::SSL.

[Catherine Khuu + Rafael Mendonça França]
2018-03-15 17:29:21 -04:00
Rafael Mendonça França
ba0ae542ca
Remove changelog header for unreleased version
We only add the header when releasing to avoid some conflicts.

[ci skip]
2018-03-13 15:20:57 -04:00
Ryuta Kamizono
9dbc475454 Remove CHANGELOG entries which were backported to 5-2-stable 2018-02-28 20:46:17 +09:00
Guillermo Iguaran
c113bdc9d0
Support for automatic nonce generation was backported to 5.2 2018-02-24 18:08:38 -05:00
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
Jeremy Daer
d4eb0dc89e Rails 6 requires Ruby 2.4.1+
Skipping over 2.4.0 to sidestep the `"symbol_from_string".to_sym.dup` bug.

References #32028
2018-02-17 15:34:57 -08:00
bogdanvlviv
88ba705609
Add changelog entry for #31844 2018-02-01 16:47:42 +02:00
Rafael Mendonça França
1c383df324 Start Rails 6.0 development!!!
🎉🎉🎉
2018-01-30 18:51:17 -05:00
Guillermo Iguaran
428939be9f Add 'Referrer-Policy' header to default headers set 2018-01-08 22:14:22 -05:00
Prathamesh Sonpatki
1bb99ae7ad
Added deprecations and removals notes for Action Pack [ci skip] 2018-01-07 21:51:51 +05:30
Prathamesh Sonpatki
fd1304d2aa
Minor cleanup of CHANGELOG of PR #30850 [ci skip] 2017-12-17 13:00:37 +05:30
Guillermo Iguaran
f1b4cd1ad4 Change the system tests to set Puma as default server only when the user haven't specified manually another server. 2017-12-09 16:46:31 -05:00
Guillermo Iguaran
5d7b70f433 Add secure X-Download-Options and X-Permitted-Cross-Domain-Policies to default headers set. 2017-12-09 15:41:55 -05:00
bogdanvlviv
82b974813b
Add headless firefox driver to System Tests 2017-12-07 20:20:54 +02:00
eileencodes
0185aae747 Add changelog entry for 9d6e28
Since this changes a default setting a changelog entry is important.
2017-11-30 12:26:33 -05:00
Guillermo Iguaran
729a3da0bb Register most popular audio/video/font mime types supported by modern browsers 2017-11-28 20:53:40 -05:00
Rafael Mendonça França
2837d0f334
Preparing for 5.2.0.beta2 release 2017-11-28 14:41:02 -05:00
Andrew White
00c0e4001c Fix optimized url helpers when using relative url root
Fixes #31220.
2017-11-28 15:58:18 +00:00
Rafael Mendonça França
cceeeb6e57
Preparing for 5.2.0.beta1 release 2017-11-27 14:50:03 -05:00
Prathamesh Sonpatki
5910c1d241
Fix CHANGELOG for CSP PR #31162 [ci skip] 2017-11-27 15:46:18 +05:30
Andrew White
723f29c0dd Add CHANGELOG.md entry for #31162 [ci skip] 2017-11-27 08:35:40 +00:00
Rafael Mendonça França
256a44c439
Merge pull request #22435 from yui-knk/fix_engine_route_test
Make `assert_recognizes` to traverse mounted engines
2017-11-06 17:24:44 -05:00
Rafael Mendonça França
e16c765ac6
Remove deprecated ActionController::ParamsParser::ParseError 2017-10-23 12:50:45 -04:00
bogdanvlviv
75597f064a
Add changelog entry about new allow_other_host option for redirect_back method [ci skip]
Related to #30850
2017-10-22 19:00:24 +03:00
yuuji.yaginuma
ada05850f8 Add headless chrome driver to System Tests 2017-10-17 07:35:48 +09:00
eileencodes
59a02fb7bc Implement H2 Early Hints for Rails
When puma/puma#1403 is merged Puma will support the Early Hints status
code for sending assets before a request has finished.

While the Early Hints spec is still in draft, this PR prepares Rails to
allowing this status code.

If the proxy server supports Early Hints, it will send H2 pushes to the
client.

This PR adds a method for setting Early Hints Link headers via Rails,
and also automatically sends Early Hints if supported from the
`stylesheet_link_tag` and the `javascript_include_tag`.

Once puma supports Early Hints the `--early-hints` argument can be
passed to the server to enable this or set in the puma config with
`early_hints(true)`. Note that for Early Hints to work
in the browser the requirements are 1) a proxy that can handle H2,
and 2) HTTPS.

To start the server with Early Hints enabled pass `--early-hints` to
`rails s`.

This has been verified to work with h2o, Puma, and Rails with Chrome.

The commit adds a new option to the rails server to enable early hints
for Puma.

Early Hints spec:
https://tools.ietf.org/html/draft-ietf-httpbis-early-hints-04

[Eileen M. Uchitelle, Aaron Patterson]
2017-10-04 09:17:21 -04:00
Ryuta Kamizono
5755f57f3e Fix indentation in CHANGELOG [ci skip] 2017-09-26 14:54:22 +09:00
Michael Coyne
8b0af54bbe Add key rotation cookies middleware
Using the action_dispatch.cookies_rotations interface, key rotation is
now possible with cookies. Thus the secret_key_base as well as salts,
ciphers, and digests, can be rotated without expiring sessions.
2017-09-24 12:23:38 -04:00
Thomas Walpole
ba04b580c6 Use the default Capybara registered puma server configuration 2017-09-18 08:48:52 -07:00
Ryuta Kamizono
0a94612a97 ✂️
[ci skip]
2017-09-07 01:01:32 +09:00
Assain
9f0b3b59ac This commit adds:
* Documentation for Duration support added  to  signed/encrypted cookies

* Changelog entries for the duration support and expiry metadata added to cookies

[ci skip]
2017-09-04 16:00:53 +05:30
yuuji.yaginuma
52422f2af6 Retrive screenshot in relative path of current directory
In Rails engine `Rails.root `returns the path of the dummy application.
Therefore, there is no `tmp` directly where the test is running, so can
not get the screenshot.
For this reason, instead of directly specifying tmp, retrive screenshot by
relative path from the current directory.

Fixes #30405
2017-08-27 20:44:01 +09:00
Trevor Wistaff
af3500b188 Deprecate ActionDispatch::TestResponse response aliases
https://github.com/rails/rails/issues/30072
2017-08-07 13:48:02 +10:00
Jon Moss
b23a01fc36 Lint actionpack/CHANGELOG.md
Fixes a few grammar things.

[ci skip]
2017-08-06 22:17:35 -04:00
Ryuta Kamizono
18d637e41c Add backticks for class names in CHANGELOG [ci skip] 2017-07-11 06:45:53 +09:00
Lisa Ugray
ec4a836919 Protect from forgery by default
Rather than protecting from forgery in the generated
ApplicationController, add it to ActionController::Base by config. This
configuration defaults to false to support older versions which have
removed it from their ApplicationController, but is set to true for
Rails 5.2.
2017-07-10 16:23:47 -04:00
Prathamesh Sonpatki
b38c370b0c
Add CHANGELOG for #29630 [ci skip] 2017-07-01 01:38:10 +05:30
Mario Alberto Chávez
9063007538 SystemTesting::Driver can register capybara-webkit and poltergeist
drivers.

When using `driver_by` with capybara-webkit or poltergeist,
SystemTesting::Driver will register the driver while passing
`screen_size` and `options` parameteres.

`options` could contain any option supported by the underlying driver.
2017-06-02 11:24:55 -05:00
Michael Coyne
5a3ba63d9a AEAD encrypted cookies and sessions
This commit changes encrypted cookies from AES in CBC HMAC mode to
Authenticated Encryption using AES-GCM. It also provides a cookie jar
to transparently upgrade encrypted cookies to this new scheme. Some
other notable changes include:

- There is a new application configuration value:
  +use_authenticated_cookie_encryption+. When enabled, AEAD encrypted
  cookies will be used.

- +cookies.signed+ does not raise a +TypeError+ now if the name of an
  encrypted cookie is used. Encrypted cookies using the same key as
  signed cookies would be verified and serialization would then fail
  due the message still be encrypted.
2017-05-22 08:50:36 +00:00