aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/middleware
Commit message (Collapse)AuthorAgeFilesLines
* 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
|
* Fix formatting of AD::FileHandler and AD::Static doc [ci skip]yuuji.yaginuma2017-06-131-7/+7
|
* set message_encryptor default cipher to aes-256-gcmAssain2017-06-121-1/+1
| | | | - Introduce a method to select default cipher, and maintain backward compatibility
* Use mattr_accessor default: option throughout the projectGenadi Samokovarov2017-06-032-8/+3
|
* Merge pull request #28132 from mikeycgto/aead-encrypted-cookiesKasper Timm Hansen2017-05-281-3/+48
|\ | | | | AEAD encrypted cookies and sessions
| * AEAD encrypted cookies and sessionsMichael Coyne2017-05-221-3/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | Define path with __dir__bogdanvlviv2017-05-231-1/+1
|/ | | | | | ".. with __dir__ we can restore order in the Universe." - by @fxn Related to 5b8738c2df003a96f0e490c43559747618d10f5f
* [docs] fix ActionDispatch documentationHrvoje Šimić2017-03-136-13/+13
|
* Remove deprecated callbacks from ActionDispatch middlewaresRafael Mendonça França2017-01-312-59/+3
|
* Reduce string objects by using \ instead of + or << for concatenating stringsAkira Matsuda2017-01-123-5/+5
| | | | (I personally prefer writing one string in one line no matter how long it is, though)
* Use already defined Encoding constant rather than freezing a StringAkira Matsuda2017-01-111-1/+1
|
* Privatize unneededly protected methods in Action PackAkira Matsuda2016-12-243-10/+10
|
* Merge pull request #26222 from vipulnsward/26134-fixRafael França2016-11-131-1/+5
|\ | | | | Format and send logs to logger.fatal from DebugExceptions
| * Format and send logs to logger.fatal from DebugExceptions instead of calling ↵Vipul A M2016-11-121-1/+5
| | | | | | | | | | | | fatal multiple times. Expose tags_text from TaggedLogging to be used for log formatting Fixes #26134
* | Merge pull request #26905 from bogdanvlviv/docsAndrew White2016-11-132-3/+3
|\ \ | |/ |/| Add missing `+` around a some literals.
| * Add missing `+` around a some literals.bogdanvlviv2016-10-272-3/+3
| | | | | | | | | | | | Mainly around `nil` [ci skip]
* | Add more rubocop rules about whitespacesRafael Mendonça França2016-10-293-5/+5
| |
* | Support plain loggers in DebugExceptionsGenadi Samokovarov2016-10-281-1/+3
|/ | | | | | | | | | | | | | I have been seeing people setting `Logger` instances for `config.logger` and it blowing up on `rails/web-console` usage. Now, I doubt many folks are manually setting `ActionView::Base.logger`, but given that `DebugExceptions` is running in a pretty fragile environment already, having it crash (and being silent) in those cases can be pretty tricky to trace down. I'm proposing we verify whether the `ActionView::Base.logger` supports silencing before we try to do it, to save us the headache of tracing it down.
* HSTS subdomains is now true, so let's fix documentation [ci skip] (#26870)प्रथमेश Sonpatki2016-10-231-1/+1
| | | - Followup of fda5afeb
* Remove deprecated `cache_control` argument from ↵Rafael Mendonça França2016-10-101-8/+1
| | | | `ActionDispatch::Static#initialize`
* Remove deprecated support to passing strings to the middleware stackRafael Mendonça França2016-10-101-20/+1
|
* Remove deprecated code in ssl middlewareRafael Mendonça França2016-10-101-21/+3
|
* Remove deprecated code in ActionDispatch::Session::SessionRestoreErrorRafael Mendonça França2016-10-101-11/+1
|
* Deprecated ActionDispatch::ParamsParser::ParamsParserRafael Mendonça França2016-10-102-31/+13
| | | | | | ActionDispatch::ParamsParser class was removed in favor of ActionDispatch::Http::Parameters so it is better to move the error constant to the new class.
* Remove deprecated ActionDispatch::ParamsParserRafael Mendonça França2016-10-101-12/+1
|
* Remove deprecated code in ActionDispatch::ParamsParser::ParseErrorRafael Mendonça França2016-10-101-17/+1
|
* [ci-skip] Swap method and its alias, format docAndrey Molchanov2016-10-041-3/+4
|
* Fix broken heredoc indentation caused by rubocop auto-correctRyuta Kamizono2016-09-031-1/+1
| | | | | | All indentation was normalized by rubocop auto-correct at 80e66cc4d90bf8c15d1a5f6e3152e90147f00772. But heredocs was still kept absolute position. This commit aligns heredocs indentation for consistency.
* fixes remaining RuboCop issues [Vipul A M, Xavier Noria]Xavier Noria2016-09-011-1/+1
|
* Start passing cipher from EncryptedCookieJar since we use it to determine ↵Vipul A M2016-09-011-7/+5
| | | | key length
* Follow up of #25602Vipul A M2016-09-011-4/+6
| | | | | | | | | Since keys are truncated, ruby 2.4 doesn't accept keys greater than their lenghts. keys of same value but different lenght and greater than key size of cipher, produce the same results as reproduced at https://gist.github.com/rhenium/b81355fe816dcfae459cc5eadfc4f6f9 Since our default cipher is 'aes-256-cbc', key length for which is 32 bytes, limit the length of key being passed to Encryptor to 32 bytes. This continues to support backwards compat with any existing signed data, already encrupted and signed with 32+ byte keys. Also fixes the passing of this value in multiple tests.
* Return 307 status instead of 301 when rerouting POST requests to SSLChirag Singhal2016-08-221-1/+9
| | | | | | | | | | | When `config.force_ssl` is set to `true`, any POST/PUT/DELETE requests coming in to non-secure url are being redirected with a 301 status. However, when that happens, the request is converted to a GET request and ends up hitting a different action on the controller. Since we can not do non-GET redirects, we can instead redirect with a 307 status code instead to indicate to the caller that a fresh request should be tried preserving the original request method. `rack-ssl` gem which was used to achieve this before we had this middleware directly baked into Rails also used to do the same, ref: https://github.com/josh/rack-ssl/blob/master/lib/rack/ssl.rb#L54 This would be specially important for any apps switching from older version of Rails or apps which expose an API through Rails.
* Add three new rubocop rulesRafael Mendonça França2016-08-165-8/+8
| | | | | | | | Style/SpaceBeforeBlockBraces Style/SpaceInsideBlockBraces Style/SpaceInsideHashLiteralBraces Fix all violations in the repository.
* applies remaining conventions across the projectXavier Noria2016-08-063-4/+0
|
* normalizes indentation and whitespace across the projectXavier Noria2016-08-069-250/+250
|
* modernizes hash syntax in actionpackXavier Noria2016-08-063-3/+3
|
* applies new string literal convention in actionpack/libXavier Noria2016-08-0619-115/+115
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.