Commit Graph

1113 Commits

Author SHA1 Message Date
Andrew White
6520ea5f7e Deprecate :controller and :action path parameters
Allowing :controller and :action values to be specified via the path
in config/routes.rb has been an underlying cause of a number of issues
in Rails that have resulted in security releases. In light of this it's
better that controllers and actions are explicitly whitelisted rather
than trying to blacklist or sanitize 'bad' values.
2016-03-01 08:48:53 +00:00
Greg Molnar
97b9e32d23 add constraint_to option to SSL middleware 2016-02-28 22:55:26 +01:00
Rafael França
0e24fcc5eb Merge pull request #23852 from prathamesh-sonpatki/hsts-subdomains
Enable HSTS with IncludeSubdomains header by default for new apps
2016-02-25 21:59:36 -03:00
Matthew Draper
ee5b621e2f Revert "Merge pull request #20851 from tomprats/indifferent-sessions"
This reverts commit 22db455dbe9c26fe6d723cac0758705d9943ea4b, reversing
changes made to 40be61dfda1e04c3f306022a40370862e3a2ce39.

This finishes off what I meant to do in 6216a092ccfe6422f113db906a52fe8ffdafdbe6.
2016-02-26 04:47:30 +10:30
Matthew Draper
6216a092cc Revert "Update Session to utilize indiffernt access"
This reverts commit 45a75a3fcc96b22954caf69be2df4e302b134d7a.

HWIAs are better than silently deeply-stringified hashes... but that's a
reaction to a shortcoming of one particular session store: we should not
break the basic behaviour of other, more featureful, session stores in
the process.

Fixes #23884
2016-02-26 03:06:38 +10:30
Prathamesh Sonpatki
31cf0f5571 Added deprecation for older apps
- For old apps which are not setting any value for hsts[:subdomains],
  a deprecation warning will be shown saying that hsts[:subdomains] will
  be turned on by default in Rails 5.1. Currently it will be set to
  false for backward compatibility.
- Adjusted tests to reflect this change.
2016-02-25 10:18:53 +05:30
Prathamesh Sonpatki
641bb39bb2 Added a test for generating Strong ETag 2016-02-24 23:16:43 +05:30
Rafael Mendonça França
22db455dbe Merge pull request #20851 from tomprats/indifferent-sessions
Give Sessions Indifferent Access
2016-02-24 00:22:04 -03:00
Jon Moss
cd8bb8b6ce Add internal attribute to routes
This is meant to provide a way for Action Cable, Sprockets, and possibly
other Rack applications to mark themselves as internal, and to exclude
themselves from the routing inspector, and thus `rails routes` / `rake
routes`.

I think this is the only way to have mounted Rack apps be marked as
internal, within AD/Journey. Another option would be to create an array
of regexes for internal apps, and then to iterate over that everytime a
request comes through. Also, I only had the first `add_route` method set
`internal`'s default to false, to avoid littering it all over the
codebase.
2016-02-22 20:30:18 -05:00
Rafael Mendonça França
4f30df4b52 Make sure we unregister the mime type before registering
Also make sure we don't change the global state of our test suite.
2016-02-22 21:22:29 -03:00
Mehmet Emin İNAÇ
97ed810cfc Use symbol of mime type instead of object to get correct parser
After registering new `:json` mime type `parsers.fetch` can't find the mime type because new mime type is not equal to old one. Using symbol of the mime type as key on parsers hash solves the problem.

Closes #23766
2016-02-22 21:22:28 -03:00
Rafael Mendonça França
c60fb74dc6 Fix typo 2016-02-17 02:17:52 -02:00
Rafael França
2572584660 Merge pull request #23712 from bf4/incorrect_to_accept_json_api_and_not_render_spec
The JSON API media type should only work wih a JSON API handler
2016-02-17 01:54:30 -02:00
Benjamin Fleischer
c4d90b70f4 The JSON API media type should only work wih a JSON API handler
Since the media type 'application/vnd.api+json' is a spec,
it is inappropriate to handle it with the JSON renderer.

This PR removes support for a JSON API media type.

I would recommend the media type be registered on its own as `jsonapi`
when a jsonapi Renderer and deserializer (Http::Parameters::DEFAULT_PARSERS) are added.

Is related to work in https://github.com/rails/rails/pull/21496
2016-02-16 21:44:23 -06:00
Mehmet Emin İNAÇ
ff8bdafec4 application/gzip added as default mime type into mime type list 2016-02-13 19:25:28 +02:00
Vipul A M
8a436fdd98 Add options for rake routes task
Add two options: `-c` and `-g`.
`-g` option returns the urls name, verb and path fields that match the pattern.
`-c` option returns the urls for specific controller.

Fixes #18902, and Fixes #20420

[Anton Davydov & Vipul A M]
2016-02-02 00:27:30 +05:30
Tom Prats
45a75a3fcc Update Session to utilize indiffernt access 2016-01-30 19:30:32 -05:00
Tom Prats
82dc8266dd Update session to have indifferent access 2016-01-29 17:22:05 -05:00
Aaron Patterson
06397336b2 Merge pull request #23140 from rails/fix-search-for-custom-routes
Fix marking of custom routes for Journey
2016-01-20 15:14:13 -08:00
Andrew White
1eace9402b Fix marking of custom routes for Journey
The Mapper build_path method marks routes where path parameters are part
of a path segment as custom routes by altering the regular expression, e.g:

    get '/foo-:bar', to: 'foo#bar'

There were some edge cases where certain constructs weren't being picked
up and this commit fixes those.

Fixes #23069.
2016-01-20 17:59:13 +00:00
abhishek
e362c31b34 Response etags to always be weak: Prefixed W/ to value returned by ActionDispatch::Http::Cache::Response#etag= such that etags set in fresh_when and stale? are weak. For #17556. 2016-01-20 07:57:30 +05:30
schneems
fe55163f11 Revert "Its ideal to set Vary: Accept-Encoding, irrespective of whether gzipped version exists or not. This is helpful for CDN's to later distinguish assets, based on previous, current copies and introduced gzip version if any."
This reverts commit 067c52f608568e35181830a5c1016e382650e655.

Conversation: https://github.com/rails/rails/pull/23120#issuecomment-173007011
2016-01-19 16:22:40 -06:00
Vipul A M
067c52f608 Its ideal to set Vary: Accept-Encoding, irrespective of whether gzipped version exists or not. This is helpful for CDN's to later distinguish assets, based on previous, current copies and introduced gzip version if any.
For ref: https://www.fastly.com/blog/best-practices-for-using-the-vary-header

This change sets `Vary` header always, to be on safer side
2016-01-19 23:48:59 +05:30
Rafael França
89f70938d7 Merge pull request #23035 from jkowens/fix-null-byte
Prevent static middleware from attempting to serve a request with a null byte
2016-01-12 19:46:42 -02:00
Jordan Owens
918f0eea97 Prevent attempt to serve a request with a null byte
File paths cannot contain null byte characters and methods that do path
operations such as Rack::Utils#clean_path_info will raise unwanted
errors.
2016-01-12 14:05:54 -05:00
Matthew Draper
272c5838df Commit before freezing the headers
This shouldn't generally come up: under a standard flow, we don't start
sending until after the commit. But application code always finds a way.
2016-01-12 11:37:42 +10:30
Edouard CHIN
ce13f79105 Better error message when running rake routes with CONTROLLER arg:
- `CONTROLLER` argument can now be supplied in different ways (Rails::WelcomeController, Rails::Welcome, rails/welcome)
- If `CONTROLLER` argument was supplied but it does not exist, will warn the user that this controller does not exist
- If `CONTROLLER` argument was supplied and no routes could be found matching this filter, will warn the user that no routes were found matching the supplied filter
- If no routes were defined in the config/routes.rb file, will warn the user with the original message
2016-01-07 06:35:40 -05:00
Prathamesh Sonpatki
70e73e4d4c Remove splat operator warning from ssl_test
- Removes following warning -

  `rails/actionpack/test/dispatch/ssl_test.rb:203: warning: `*' interpreted as argument prefix`.
2016-01-07 13:53:10 +05:30
Prathamesh Sonpatki
a31078556a Allow AC::Parameters as an argument to url_helpers
- Earlier only Hash was allowed as params argument to url_helpers.
- Now ActionController::Parameters instances will also be allowed.
- If the params are not secured then it will raise an ArgumentError to
  indicate that constructing URLs with non-secure params is not recommended.
- Fixes #22832.
2016-01-07 12:12:34 +05:30
Rafael França
1f85e1c9f3 Merge pull request #22826 from timrogers/actiondispatch-ssl-config
Configurable redirect and secure cookies for ActionDispatch::SSL
2015-12-31 03:25:47 -02:00
Jorge Bejar
44ca804229 Format from Accept headers have higher precedence than path extension format 2015-12-29 13:43:14 -03:00
Jorge Bejar
9a85da9367 Rely on default Mime format when MimeNegotiation#format_from_path_extension is not a valid type
Closes #22747
2015-12-29 13:42:57 -03:00
Tim Rogers
32b1c90837 Flexible configuration for ActionDispatch::SSL 2015-12-29 13:07:51 +00:00
Rafael Mendonça França
d182c22e91 Currectly test the Middleware#== 2015-12-22 17:09:26 -02:00
Jon Moss
0c5287a668 Add #== back to ActionDispatch::MiddlewareStack::Middleware
This was causing bug #22738 to occur. Also added extra tests to make
sure everything is A-OK.
2015-12-21 19:55:10 -05:00
Maxime Garcia
d3dd3847bc Don't catch all NameError to reraise as ActionController::RoutingError #22368 2015-12-12 11:22:08 +01:00
Jorge Bejar
84e8accd6f Do not add format key to request_params
I did this change but it is affecting how the request params end up
after being processed by the router.

To be in the safe side, I just take the format from the extension in the
URL when is not present in those params and it's being used only for the
`Request#formats` method
2015-12-09 10:53:46 -03:00
Jorge Bejar
6fa2023c81 DebugException initialize with a response_format value 2015-12-09 10:53:45 -03:00
Jorge Bejar
05d89410bf Fix some edge cases in AD::DebugExceptions in rails api apps 2015-12-09 10:53:44 -03:00
Jorge Bejar
83b4e9073f Response when error should be formatted properly in Rails API if local request 2015-12-09 10:53:41 -03:00
Jorge Bejar
b79bfaadaf Use URL path extension as format in bad params exception handling 2015-12-08 21:23:47 -03:00
eileencodes
492b134433 Push before_sending to super class
We want to get rid of the `Live::Response` so we are consolidating methods
from `Live::Response` and `Response` by merging them together.

This adds an `#empty` method to the request so we don't need to
hard-code the empty array each time we call an empty
`ActionDispatch::Request`.

The work here is a continuation on combining controller and integration
test code bases into one.
2015-12-06 15:32:40 -05:00
Will Jessop
e8bfaa58bd Test against the real value of tld_length unless explicitly set
There were two places where the tld_length default
was hard-coded to 1, both overriding the real default
value of ActionDispatch::Http::URL.tld_length in this
set of tests.

This commit removes both of those, relying on the
actual value of ActionDispatch::Http::URL.tld_length,
unless it's specifically overridden.
2015-12-04 16:40:08 +00:00
Arthur Nogueira Neves
3513f80e53 Merge pull request #22371 from yui-knk/better_mount_error
Brush up errors of `ActionDispatch::Routing::Mapper#mount`
2015-11-28 11:29:46 -05:00
yui-knk
f8f7e66f5f Brush up errors of ActionDispatch::Routing::Mapper#mount
* Integrate to raise `ArgumentError`
* Detailed error message when `path` is not defined
* Add a test case, invalid rack app is passed
2015-11-28 10:50:11 +09:00
Arthur Nogueira Neves
9afb0b9c43 Merge pull request #21241 from pdg137/master
In url_for, never append ? when the query string is empty anyway.
2015-11-26 16:10:46 -05:00
Rafael França
40acdcfb7c Merge pull request #22172 from tijmenb/fix-source-in-show-exception
Add text template for source code
2015-11-24 02:11:09 -02:00
Sean Griffin
8404ed6408 Merge pull request #17928 from sergey-alekseev/remove-unused-form-data-method 2015-11-23 14:33:11 -07:00
Jake Worth
432c7a5b76 Fix typo [ci skip] 2015-11-12 10:06:44 -06:00
Jerry D'Antonio
23b6f65fd1 Require only necessary concurrent-ruby classes. 2015-11-04 21:12:28 -05:00