aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/middleware
Commit message (Collapse)AuthorAgeFilesLines
* Avoid extra array allocationsSamuel Cochran2018-11-291-2/+2
|
* Log exceptions atomicallySamuel Cochran2018-11-281-5/+8
| | | | | | When distributed over multiple logger calls the lines can become intermixed with other log statements. Combining them into a single logger call makes sure they always get logged together.
* Add `Style/RedundantFreeze` to remove redudant `.freeze`Yasuo Honda2018-09-296-30/+30
| | | | | | | | | | | | | | | | | | | | | Since Rails 6.0 will support Ruby 2.4.1 or higher `# frozen_string_literal: true` magic comment is enough to make string object frozen. This magic comment is enabled by `Style/FrozenStringLiteralComment` cop. * Exclude these files not to auto correct false positive `Regexp#freeze` - 'actionpack/lib/action_dispatch/journey/router/utils.rb' - 'activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb' It has been fixed by https://github.com/rubocop-hq/rubocop/pull/6333 Once the newer version of RuboCop released and available at Code Climate these exclude entries should be removed. * Replace `String#freeze` with `String#-@` manually if explicit frozen string objects are required - 'actionpack/test/controller/test_case_test.rb' - 'activemodel/test/cases/type/string_test.rb' - 'activesupport/lib/active_support/core_ext/string/strip.rb' - 'activesupport/test/core_ext/string_ext_test.rb' - 'railties/test/generators/actions_test.rb'
* Enable `Performance/UnfreezeString` copyuuji.yaginuma2018-09-233-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In Ruby 2.3 or later, `String#+@` is available and `+@` is faster than `dup`. ```ruby # frozen_string_literal: true require "bundler/inline" gemfile(true) do source "https://rubygems.org" gem "benchmark-ips" end Benchmark.ips do |x| x.report('+@') { +"" } x.report('dup') { "".dup } x.compare! end ``` ``` $ ruby -v benchmark.rb ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux] Warming up -------------------------------------- +@ 282.289k i/100ms dup 187.638k i/100ms Calculating ------------------------------------- +@ 6.775M (± 3.6%) i/s - 33.875M in 5.006253s dup 3.320M (± 2.2%) i/s - 16.700M in 5.032125s Comparison: +@: 6775299.3 i/s dup: 3320400.7 i/s - 2.04x slower ```
* Focus search input after page load on /rails/info/routes (#33683)James Brooks2018-08-281-0/+3
|
* Purpose Metadata For Signed And Encrypted CookiesAssain2018-08-121-13/+29
| | | | | | | | | | | | | | | | Purpose metadata prevents cookie values from being copy-pasted and ensures that the cookie is used only for its originally intended purpose. The Purpose and Expiry metadata are embedded inside signed/encrypted cookies and will not be readable on previous versions of Rails. We can switch off purpose and expiry metadata embedded in signed and encrypted cookies using config.action_dispatch.use_cookies_with_metadata = false if you want your cookies to be readable on older versions of Rails.
* Enable Start/EndWith and RegexpMatch copsBart de Water2018-07-281-1/+1
| | | | | In cases where the MatchData object is not used, this provides a speed-up: https://github.com/JuanitoFatas/fast-ruby/#stringmatch-vs-stringmatch-vs-stringstart_withstringend_with-code-start-code-end
* Merge pull request #33229 from ↵Matthew Draper2018-07-252-2/+2
|\ | | | | | | | | albertoalmagro/albertoalmagro/prefer-rails-command-over-bin-rails Prefer rails command over bin/rails
| * Recommend use of rails over bin/railsAlberto Almagro2018-07-062-2/+2
| | | | | | | | | | | | | | | | | | As discussed in #33203 rails command already looks for, and runs, bin/rails if it is present. We were mixing recommendations within guides and USAGE guidelines, in some files we recommended using rails, in others bin/rails and in some cases we even had both options mixed together.
* | Show nested exceptions on the debug viewYuki Nishijima2018-07-159-62/+109
| |
* | Enable `Layout/EmptyLinesAroundBlockBody` to reduce review cost in the futureRyuta Kamizono2018-07-121-1/+0
|/ | | | | | | We sometimes ask "✂️ extra blank lines" to a contributor in reviews like https://github.com/rails/rails/pull/33337#discussion_r201509738. It is preferable to deal automatically without depending on manpower.
* Remove reference to session_store.rb initializerJustin Searls2018-06-121-1/+1
| | | | | | | | Rails no longer generates this file, but Google is still packed with results suggesting it should exist, so that the doc still pointed me to it threw me off (had I deleted it or something?). Probably be better to be vague and prompt the user to stick it in a config file they own. #33124
* Use the same tag as other views to display the error messageyuuji.yaginuma2018-04-231-1/+1
| | | | | | | | | Since other views use the `h2` tag, should also use `h2` on `missing_exact_template.html.erb`. https://github.com/rails/rails/blob/76acaf6eb9ef3635e4c6f2ca9dba34edb50f541d/actionpack/lib/action_dispatch/middleware/templates/rescues/routing_error.html.erb#L5 https://github.com/rails/rails/blob/76acaf6eb9ef3635e4c6f2ca9dba34edb50f541d/actionpack/lib/action_dispatch/middleware/templates/rescues/diagnostics.html.erb#L11 https://github.com/rails/rails/blob/76acaf6eb9ef3635e4c6f2ca9dba34edb50f541d/actionpack/lib/action_dispatch/middleware/templates/rescues/unknown_action.html.erb#L5
* Fix Style/RedundantReturn offensesBart de Water2018-04-211-1/+1
|
* Merge pull request #29286 from vinistock/create_missing_exact_template_exceptionRafael Mendonça França2018-04-203-5/+29
|\ | | | | | | Create MissingExactTemplate exception with separate template
| * Create MissingExactTemplate exception with separate templateVinicius Stock2018-04-203-5/+29
| |
* | Introduce ActionDispatch::DebugExceptions interceptorsGenadi Samokovarov2018-04-201-1/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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`.
* | Fix broken nodocsChris Arcand2018-04-131-1/+1
| | | | | | | | | | This commit fixes all references in the codebase missing a trailing :, which causes the nodoc not to actually work :) [skip ci]
* | Use ASCII-8BIT paths in ActionDispatch::StaticAndrew White2018-03-221-3/+3
| | | | | | | | | | | | | | | | | | | | The rack gem returns PATH_INFO as an ASCII-8BIT encoded string but it was being converted to US-ASCII by the match? method because it was calling Rack::Utils.escape_path. To prevent incompatibile encoding warnings use ASCII-8BIT strings for the root path and let Ruby handle any filename encoding conversion. Fixes #32294, Closes #32314.
* | Check exclude before flagging cookies as secure in ActionDispatch::SSL (#32262)Catherine Khuu2018-03-151-1/+3
| | | | | | | | | | | | | | * Check exclude before flagging cookies as secure. * Update comments in ActionDispatch::SSL. [Catherine Khuu + Rafael Mendonça França]
* | Merge branch 'master' into update_default_hsts_max_ageGuillermo Iguaran2018-02-242-1/+4
|\|
| * Consistent behavior for session and cookies with to_h and to_hash methodIgor Kasyanchuk2018-01-311-0/+3
| |
| * Allow @ in X-Request-Id headerDaniel Colson2018-01-291-1/+1
| | | | | | | | | | | | | | It makes sense to be as strict as possible with headers from the outside world, but allowing @ to support Apache's mod_unique_id (see #31644) seems OK to me
* | Update default HSTS max-age value to 1 yearGrant Bourque2018-01-161-5/+4
|/ | | | | - Update the default HSTS max-age value to 31536000 seconds (1 year) to meet the minimum max-age requirement for https://hstspreload.org/.
* Help if Active Storage tables are missingClaudio B2017-12-213-0/+35
| | | | | | When a user tries to create a new attachment or blog and the matching table is missing from the database (`active_storage_attachments` and `active_storage_blobs` by default), an informative error is displayed that invites users to run the `active_storage:install` task.
* Fix tld_length documentationJoe Marty2017-11-211-1/+1
| | | Change recommendation for tld_length (for sharing cookies across subdomains of a 2-token TLD), to 2 instead of 1.
* Prevent source line wrapping in rescue layoutDave Gynn2017-10-311-0/+1
| | | | | | Long source lines cause line wrapping in the extracted source section of the rescue handler page which can make the line numbers not match up with the source lines.
* [Action Pack] require => require_relativeAkira Matsuda2017-10-216-10/+10
| | | | | This basically reverts e9fca7668b9eba82bcc832cb0061459703368397, d08da958b9ae17d4bbe4c9d7db497ece2450db5f, d1fe1dcf8ab1c0210a37c2a78c1ee52cf199a66d, and 68eaf7b4d5f2bb56d939f71c5ece2d61cf6680a3
* Don't use Active Support where it is not needed.yuuji.yaginuma2017-09-301-1/+1
| | | | | | | | | This code has been changed with https://github.com/rails/rails/pull/30735/files#diff-8e5f6b33c191ad6dec07f3288345a13fL47. However, `active_support/time` is not load automatically, so if use Action Pack alone, `days` method can not use and an error occurs. In this case, I think that there is no problem by specifying a value with Integer.
* Merge pull request #30735 from tjschuck/fix_doc_code_formattingEileen M. Uchitelle2017-09-291-33/+38
|\ | | | | Fix formatting in ActionDispatch::SSL middleware docs
| * Fix formatting in ActionDispatch::SSL middleware docsT.J. Schuck2017-09-271-33/+38
| | | | | | | | | | | | | | Before: https://monosnap.com/file/J6xewF0tYpm6dC9nSTe82ddsHAOcM5.png After: https://monosnap.com/file/0tCYicLXNqRHAEMDb81u0aLb3gH9Wf.png [ci skip]
* | Merge pull request #30709 from ↵Kasper Timm Hansen2017-09-281-3/+10
|\ \ | |/ |/| | | | | mikeycgto/actiondispatch-use-aead-encrypted-cookies-patch Fixes for use_authenticated_cookie_encryption
| * Fixes for use_authenticated_cookie_encryptionMichael Coyne2017-09-271-3/+10
| | | | | | | | Use CBC encryption is this configuration value is set to false
* | Fix cookies/session tests broken after merging key rotation.Kasper Timm Hansen2017-09-251-2/+3
|/ | | | | | | | | | | | Based on, yet closes https://github.com/rails/rails/pull/30708 Fix the session test by properly truncating the legacy encryption key for cbc encryption. Borrowed straight from 👆. Fix the cookies test a little differently than the PR. Basically keep every config within the config block. [ Michael Coyne & Kasper Timm Hansen ]
* Fix "warning: `*' interpreted as argument prefix"Ryuta Kamizono2017-09-251-2/+2
|
* Use new rotation signature in cookies.Kasper Timm Hansen2017-09-241-11/+12
| | | | [ Michael Coyne & Kasper Timm Hansen ]
* Add key rotation cookies middlewareMichael Coyne2017-09-241-100/+82
| | | | | | 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.
* [ci skip] Prefer credentials to secrets in docs.Kasper Timm Hansen2017-09-132-28/+12
| | | | | | | Removes most mentions of secrets.secret_key_base and explains credentials instead. Also removes some very stale upgrade notices about Rails 3/4.
* Add credentials using a generic EncryptedConfiguration class (#30067)David Heinemeier Hansson2017-09-111-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * WIP: Add credentials using a generic EncryptedConfiguration class This is sketch code so far. * Flesh out EncryptedConfiguration and test it * Better name * Add command and generator for credentials * Use the Pathnames * Extract EncryptedFile from EncryptedConfiguration and add serializers * Test EncryptedFile * Extract serializer validation * Stress the point about losing comments * Allow encrypted configuration to be read without parsing for display * Use credentials by default and base them on the master key * Derive secret_key_base in test/dev, source it from credentials in other envs And document the usage. * Document the new credentials setup * Stop generating the secrets.yml file now that we have credentials * Document what we should have instead Still need to make it happen, tho. * [ci skip] Keep wording to `key base`; prefer defaults. Usually we say we change defaults, not "spec" out a release. Can't use backticks in our sdoc generated documentation either. * Abstract away OpenSSL; prefer MessageEncryptor. * Spare needless new when raising. * Encrypted file test shouldn't depend on subclass. * [ci skip] Some woordings. * Ditch serializer future coding. * I said flip it. Flip it good. * [ci skip] Move require_master_key to the real production.rb. * Add require_master_key to abort the boot process. In case the master key is required in a certain environment we should inspect that the key is there and abort if it isn't. * Print missing key message and exit immediately. Spares us a lengthy backtrace and prevents further execution. I've verified the behavior in a test app, but couldn't figure the test out as loading the app just exits immediately with: ``` /Users/kasperhansen/Documents/code/rails/activesupport/lib/active_support/testing/isolation.rb:23:in `load': marshal data too short (ArgumentError) from /Users/kasperhansen/Documents/code/rails/activesupport/lib/active_support/testing/isolation.rb:23:in `run' from /Users/kasperhansen/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/minitest-5.10.2/lib/minitest.rb:830:in `run_one_method' from /Users/kasperhansen/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/minitest-5.10.2/lib/minitest/parallel.rb:32:in `block (2 levels) in start' ``` It's likely we need to capture and prevent the exit somehow. Kernel.stub(:exit) didn't work. Leaving it for tomorrow. * Fix require_master_key config test. Loading the app would trigger the `exit 1` per require_master_key's semantics, which then aborted the test. Fork and wait for the child process to finish, then inspect the exit status. Also check we aborted because of a missing master key, so something else didn't just abort the boot. Much <3 to @tenderlove for the tip. * Support reading/writing configs via methods. * Skip needless deep symbolizing. * Remove save; test config reader elsewhere. * Move secret_key_base check to when we're reading it. Otherwise we'll abort too soon since we don't assign the secret_key_base to secrets anymore. * Add missing string literal comments; require unneeded yaml require. * ya ya ya, rubocop. * Add master_key/credentials after bundle. Then we can reuse the existing message on `rails new bc4`. It'll look like: ``` Using web-console 3.5.1 from https://github.com/rails/web-console.git (at master@ce985eb) Using rails 5.2.0.alpha from source at `/Users/kasperhansen/Documents/code/rails` Using sass-rails 5.0.6 Bundle complete! 16 Gemfile dependencies, 72 gems now installed. Use `bundle info [gemname]` to see where a bundled gem is installed. Adding config/master.key to store the master encryption key: 97070158c44b4675b876373a6bc9d5a0 Save this in a password manager your team can access. If you lose the key, no one, including you, can access anything encrypted with it. create config/master.key ``` And that'll be executed even if `--skip-bundle` was passed. * Ensure test app has secret_key_base. * Assign secret_key_base to app or omit. * Merge noise * Split options for dynamic delegation into its own method and use deep symbols to make it work * Update error to point to credentials instead * Appease Rubocop * Validate secret_key_base when reading it. Instead of relying on the validation in key_generator move that into secret_key_base itself. * Fix generator and secrets test. Manually add config.read_encrypted_secrets since it's not there by default anymore. Move mentions of config/secrets.yml to config/credentials.yml.enc. * Remove files I have no idea how they got here. * [ci skip] swap secrets for credentials. * [ci skip] And now, changelogs are coming.
* This commit adds:Assain2017-09-041-4/+7
| | | | | | | | * Documentation for Duration support added to signed/encrypted cookies * Changelog entries for the duration support and expiry metadata added to cookies [ci skip]
* Fix `warning: shadowing outer local variable`yuuji.yaginuma2017-08-281-3/+3
| | | | | | | | This fixes following warnings: ``` actionpack/lib/action_dispatch/middleware/debug_locks.rb:46: warning: shadowing outer local variable - threads ```
* Fix `can't modify frozen String` error in `DebugLocks`yuuji.yaginuma2017-08-281-4/+4
| | | | | | | | | | | | | | Without this, `DebugLocks` middleware raises an error as follwing: ``` Puma caught this error: can't modify frozen String (RuntimeError) actionpack/lib/action_dispatch/middleware/debug_locks.rb:97:in `block in render_details' actionpack/lib/action_dispatch/middleware/debug_locks.rb:64:in `each' actionpack/lib/action_dispatch/middleware/debug_locks.rb:64:in `map' actionpack/lib/action_dispatch/middleware/debug_locks.rb:64:in `render_details' actionpack/lib/action_dispatch/middleware/debug_locks.rb:37:in `call' railties/lib/rails/engine.rb:524:in `call' ```
* Use tt in doc for ActionPack [ci skip]Yoshiyuki Hirano2017-08-262-7/+7
|
* Update links to use https link instead of http [ci skip]Yoshiyuki Hirano2017-08-222-3/+3
|
* freshen :expires option with duration support and add expiry metadata to cookiesAssain2017-08-201-3/+15
|
* Use frozen string literal in actionpack/Kir Shatrov2017-07-2916-0/+32
|
* Fix search input's type & placeholder conflict in Routing Error pageKaan Kölköy2017-07-261-0/+4
|
* [Action Pack] `rubocop -a --only Layout/EmptyLineAfterMagicComment`Koichi ITO2017-07-113-0/+3
|
* Prepare AP and AR to be frozen string friendlyKir Shatrov2017-07-063-4/+7
|
* [Action Dispatch] require => require_relativeAkira Matsuda2017-07-016-10/+10
|