Commit Graph

213 Commits

Author SHA1 Message Date
Rafael Mendonça França
03351cd541
Remove deprecated force_ssl at the controller level. 2020-05-05 00:58:54 -04:00
George Claghorn
75a53297c7
Add ActionController::Base.log_at
Allow setting a different log level per request.
2019-09-24 13:47:34 -04:00
Eugene Kenny
aaa9b669f8 Allow ActionDispatch::Response to be autoloaded
Similar to b744372f2dfd3d86f7eb4af99b1f9049e21f3d44, this defers loading
`ActionDispatch::Response` until after initialization, which will allow
applications to boot a bit faster in development but also paves the way
for `return_only_media_type_on_content_type` to work correctly when set
from `new_framework_defaults_6_0.rb`.

Benchmark:

    $ cat test.rb
    require "bundler/setup"
    before = ObjectSpace.each_object(Module).count
    start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
    require "action_controller"
    finish = Process.clock_gettime(Process::CLOCK_MONOTONIC)
    after = ObjectSpace.each_object(Module).count
    puts "took #{finish - start} and created #{after - before} modules"

Before:

    $ ruby test.rb
    took 0.35654300000169314 and created 608 modules

After:

    $ ruby test.rb
    took 0.2770050000108313 and created 466 modules

Co-authored-by: Serena Fritsch <serena@intercom.io>
2019-09-17 23:38:01 +01:00
Akira Matsuda
3676544141 active_support/rails has to be required via abstract_controller.rb 2019-07-12 18:33:31 +09:00
Jacob Bednarz
bf19b8774e Adds support for configuring HTTP Feature Policy (#33439)
A HTTP feature policy is Yet Another HTTP header for instructing the
browser about which features the application intends to make use of and
to lock down access to others. This is a new security mechanism that
ensures that should an application become compromised or a third party
attempts an unexpected action, the browser will override it and maintain
the intended UX.

WICG specification: https://wicg.github.io/feature-policy/

The end result is a HTTP header that looks like the following:

```
Feature-Policy: geolocation 'none'; autoplay https://example.com
```

This will prevent the browser from using geolocation and only allow
autoplay on `https://example.com`. Full feature list can be found over
in the WICG repository[1].

As of today Chrome and Safari have public support[2] for this
functionality with Firefox working on support[3] and Edge still pending
acceptance of the suggestion[4].

#### Examples

Using an initializer

```rb
# config/initializers/feature_policy.rb
Rails.application.config.feature_policy do |f|
  f.geolocation :none
  f.camera      :none
  f.payment     "https://secure.example.com"
  f.fullscreen  :self
end
```

In a controller

```rb
class SampleController < ApplicationController
  def index
    feature_policy do |f|
      f.geolocation "https://example.com"
    end
  end
end
```

Some of you might realise that the HTTP feature policy looks pretty
close to that of a Content Security Policy; and you're right. So much so
that I used the Content Security Policy DSL from #31162 as the starting
point for this change.

This change *doesn't* introduce support for defining a feature policy on
an iframe and this has been intentionally done to split the HTTP header
and the HTML element (`iframe`) support. If this is successful, I'll
look to add that on it's own.

Full documentation on HTTP feature policies can be found at
https://wicg.github.io/feature-policy/. Google have also published[5] a
great in-depth write up of this functionality.

[1]: https://github.com/WICG/feature-policy/blob/master/features.md
[2]: https://www.chromestatus.com/feature/5694225681219584
[3]: https://bugzilla.mozilla.org/show_bug.cgi?id=1390801
[4]: https://wpdev.uservoice.com/forums/257854-microsoft-edge-developer/suggestions/33507907-support-feature-policy
[5]: https://developers.google.com/web/updates/2018/06/feature-policy
2019-07-10 15:33:15 -07: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
Andrew White
456c3ffdbe Add DSL for configuring Content-Security-Policy header
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy
2017-11-27 05:59:26 +00:00
Akira Matsuda
b0d0c9f40d [Action Pack] require => require_relative
This basically reverts e9fca7668b9eba82bcc832cb0061459703368397, d08da958b9ae17d4bbe4c9d7db497ece2450db5f,
d1fe1dcf8ab1c0210a37c2a78c1ee52cf199a66d, and 68eaf7b4d5f2bb56d939f71c5ece2d61cf6680a3
2017-10-21 22:48:28 +09:00
Kir Shatrov
dfcc766163 Use frozen string literal in actionpack/ 2017-07-29 14:02:40 +03:00
Akira Matsuda
d1fe1dcf8a [Action Controller] require => require_relative 2017-07-01 18:38:04 +09:00
David Heinemeier Hansson
debd774d63 Include the content of the flash in the auto-generated etag (#26250)
Include the content of the flash in the auto-generated etag
2016-08-22 13:34:35 -07:00
Kerri Miller
496d744fa3 Allow specifying encoding of parameters by action
At GitHub we need to handle parameter encodings that are not UTF-8. This
patch allows us to specify encodings per parameter per action.
2016-08-09 15:43:01 -07:00
Xavier Noria
628e51ff10 applies new string literal convention in actionpack/lib
The current code base is not uniform. After some discussion,
we have chosen to go with double quotes by default.
2016-08-06 18:51:43 +02:00
Rafael Mendonça França
40fa818580 Move Caching module to Abstract Controller
Abstract Controller is the common component between Action Mailer and
Action Controller so if we need to share the caching component it need
to be there.
2016-02-23 21:11:15 -03:00
Jon Moss
77acc004ef Re-add ActionController::ApiRendering
- Fixes bug #23142.
- Bug was occurring only with ActionController::API, because `_process_options` wasn't being run for API requests, even though it was being run for normal app requests.
2016-01-20 19:16:23 -05:00
Aaron Patterson
d47438745e remove RackDelegation module
Since all controller instances are required to have a request and
response object, RackDelegation is no longer needed (we always have to
delegate to the response)
2015-08-26 11:53:15 -07:00
Jorge Bejar
6c16577311 Return 204 if render is not called in API controllers 2015-06-11 16:54:17 -03:00
Jorge Bejar
fd2508522c Remove Compatibility module since we don't remember why it was added 😄 2015-06-11 16:54:14 -03:00
Santiago Pastorino
38818c93a9 Remove api_rendering is not needed 2015-06-11 16:54:13 -03:00
Santiago Pastorino
032778eefb Add ActionController API functionality 2015-06-11 16:54:09 -03:00
Kevin McPhillips
2b8acdcd21 Override default form builder for a controller 2015-04-13 23:43:34 -04:00
brainopia
801e399e42 Add ActionController::Renderer
Render arbitrary templates outside of controller actions
2015-01-22 01:02:11 +03:00
yuuji.yaginuma
e3be421cc1 remove autoload HideActions, no longer exist 2015-01-11 21:13:59 +09:00
Akira Matsuda
fe88af61f6 Responder was removed at ee77770d57de9da87b05a2fe84b9d46ec6852c62 2014-09-30 17:21:48 +09:00
Jeremy Kemper
6c96602bc1 When your templates change, browser caches bust automatically.
New default: the template digest is automatically included in your ETags.
When you call `fresh_when @post`, the digest for `posts/show.html.erb`
is mixed in so future changes to the HTML will blow HTTP caches for you.
This makes it easy to HTTP-cache many more of your actions.

If you render a different template, you can now pass the `:template`
option to include its digest instead:

  fresh_when @post, template: 'widgets/show'

Pass `template: false` to skip the lookup. To turn this off entirely, set:

  config.action_controller.etag_with_template_digest = false
2014-08-17 06:52:17 -07:00
Genadi Samokovarov
6329d9fa8b Remove deprecated cattr_* requires 2013-12-03 00:28:15 +02:00
José Valim
1385ae138d Remove BasicRendering tests 2013-09-09 16:10:41 -03:00
Łukasz Strzałkowski
c40c362ec1 Load HTML in ActionView not ActionPack
HTML Scanner is part of ActionView and it should be loaded along with it
2013-08-25 11:40:10 +02:00
Łukasz Strzałkowski
aa2d003812 Fist stab on basic rendering 2013-08-25 11:39:13 +02:00
Łukasz Strzałkowski
6c7d895dda Do not load AV inside AP
Move that part to AV railtie
2013-08-25 11:39:12 +02:00
Carlos Antonio da Silva
b990921f05 Remove deprecated constants autoload
These constants were removed in 4b97ce5eb16cc20207516387fba98bf577e2e281,
but I forgot to remove the autoload calls .
2013-07-02 22:53:37 -03:00
kennyj
d8c6f52d3b Remove ActionController::RecordIdentifier was deprecated. 2013-06-01 23:22:12 +09:00
Yves Senn
3e1ed7818b extract PerformanceTest into rails-performance_tests gem 2013-01-10 17:09:06 +01:00
Guillermo Iguaran
1aaf4490b2 Add config.action_controller.permit_all_attributes to bypass StrongParameters protection 2012-09-16 23:58:21 -05:00
Guillermo Iguaran
885005461b Integrate ActionController::Parameters from StrongParameters gem 2012-09-16 23:58:19 -05:00
Dmitry Vorotilin
3a6e8e464c Sprockets-rails tests fail
Method invalid_asset_host! was delegated to controller but sprockets
compile assets in their own scope without controller. And if we set asset_host
with second parameter it should raise error through invalid_asset_host!.
But since controller is nil it cannot be reached.
2012-09-01 16:22:40 +04:00
Piotr Sarnacki
dc663dd52c Don't require action_dispatch in ActionView::UrlHelpers
ActionDispatch::Routing::UrlFor was always required in UrlHelpers. This
was changed by splitting previous implementation of UrlHelper into 2
modules: ActionView::Helpers::UrlHelper and
ActionView::Routing::UrlHelper. The former one keeps only basic
implementation of url_for. The latter adds features that allow to use
routes and is only required when url_helpers or mounted_helpers are
required.
2012-08-28 11:19:29 +02:00
Piotr Sarnacki
ba83aa7f03 Move action_controller/vendor/html-scanner to action_view
This is another step in moving Action View's dependencies in Action Pack
to Action View itself. Also, HtmlScanner seems to be better suited for
views rather than controllers.
2012-08-28 10:51:03 +02:00
Piotr Sarnacki
4efad291c1 Deprecate ActionController::RecordIdentifier 2012-08-28 10:51:03 +02:00
Piotr Sarnacki
264624049e Move ActionController::RecordIdentifier to ActionView
Since it's more about DOM classes and ids it belongs to Action View
better. What's more, it's more convenient to make it part of Action View
to follow the rule that Action Pack can depend on Action View, but not
the other way round.
2012-08-28 10:51:03 +02:00
Piotr Sarnacki
7185e35971 Remove dependency on actionpack in ActionView::AssetPaths
Since Action View should not depend on actionpack, it's best to delegate
invalid_asset_host! to controller and just rely on such simple contract
instead of raising ActionController::RoutingError directly.
2012-08-28 10:51:03 +02:00
José Valim
2801786e1a Get rid of config.preload_frameworks in favor of config.eager_load_namespaces
The new option allows any Ruby namespace to be registered and set
up for eager load. We are effectively exposing the structure existing
in Rails since v3.0 for all developers in order to make their applications
thread-safe and CoW friendly.
2012-08-21 14:47:19 -03:00
Xavier Noria
4aee8dd486 load active_support/core_ext/module/delegation in active_support/rails 2012-08-02 21:59:23 +02:00
Xavier Noria
64bc8447c2 load active_support/concern in active_support/rails 2012-08-02 21:59:23 +02:00
Xavier Noria
1a7b2e8fad defines a private require-hub active_support/rails
This is a private place to put those AS features that are used
by every component. Nowadays we cherry-pick individual files
wherever they are used, but that it is not worth the effort
for stuff that is going to be loaded for sure sooner or later,
like blank?, autoload, concern, etc.
2012-08-02 21:59:22 +02:00
Aaron Patterson
af0a9f9eef added live responses which can be written and read in separate threads 2012-07-29 21:43:05 -07:00
José Valim
6db930cb5b Remove --http. 2012-03-14 22:30:01 +01:00
Santiago Pastorino
4c16791f35 Add ActionController::HTTP
More info http://edgeguides.rubyonrails.org/api_app.html

[Carlos Antonio da Silva & Santiago Pastorino]
2012-03-14 12:46:23 -03:00
Santiago Pastorino
bc5ac778c0 Remove unused ActionController::SessionManagement 2012-03-06 17:57:12 -02:00
Vishnu Atrai
95a935610c remove autoload UrlWriter, no longer exists 2012-01-29 17:00:37 +05:30