diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2015-08-11 09:00:49 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2015-08-11 09:00:49 -0300 |
commit | 99ae9b1698077cf4590014efd62dfe117d38d785 (patch) | |
tree | c37edc6b3a91c84bc9bcc39b83efdbecc4d2d405 | |
parent | 94db733561844ca7d6bcae2cc1ce0328efe5505f (diff) | |
parent | a42ca131a539a80d687b352a90ad2d665e59e0bc (diff) | |
download | rails-99ae9b1698077cf4590014efd62dfe117d38d785.tar.gz rails-99ae9b1698077cf4590014efd62dfe117d38d785.tar.bz2 rails-99ae9b1698077cf4590014efd62dfe117d38d785.zip |
Merge pull request #21138 from dhiachou/patch-2
Outdated information about session storage updated [ci skip]
-rw-r--r-- | guides/source/security.md | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/guides/source/security.md b/guides/source/security.md index 485b108d12..c5c0e9bcf6 100644 --- a/guides/source/security.md +++ b/guides/source/security.md @@ -93,9 +93,11 @@ Rails 2 introduced a new default session storage, CookieStore. CookieStore saves * Cookies imply a strict size limit of 4kB. This is fine as you should not store large amounts of data in a session anyway, as described before. _Storing the current user's database id in a session is usually ok_. -* The client can see everything you store in a session, because it is stored in clear-text (actually Base64-encoded, so not encrypted). So, of course, _you don't want to store any secrets here_. To prevent session hash tampering, a digest is calculated from the session with a server-side secret and inserted into the end of the cookie. +* The client can see everything you store in a session, because it is stored in clear-text (actually Base64-encoded, so not encrypted). So, of course, _you don't want to store any secrets here_. To prevent session hash tampering, a digest is calculated from the session with a server-side secret (`secrets.secret_token`) and inserted into the end of the cookie. -That means the security of this storage depends on this secret (and on the digest algorithm, which defaults to SHA1, for compatibility). So _don't use a trivial secret, i.e. a word from a dictionary, or one which is shorter than 30 characters_. +However, since Rails 4, the default store is EncryptedCookieStore. With EncryptedCookieStore the session is encrypted before being stored in a cookie. This prevents the user access to the content of the cookie and prevents him from tampering its content as well. Thus the session becomes a more secure place to store data. The encryption is done using a server-side secret key `secrets.secret_key_base` stored in `config/secrets.yml`. + +That means the security of this storage depends on this secret (and on the digest algorithm, which defaults to SHA1, for compatibility). So _don't use a trivial secret, i.e. a word from a dictionary, or one which is shorter than 30 characters, use `rake secret` instead_. `secrets.secret_key_base` is used for specifying a key which allows sessions for the application to be verified against a known secure key to prevent tampering. Applications get `secrets.secret_key_base` initialized to a random key present in `config/secrets.yml`, e.g.: |