You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: guides/source/active_record_encryption.md
+12-12Lines changed: 12 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -82,8 +82,8 @@ There is an important concern about string column sizes: in modern databases the
82
82
83
83
In practice, this means:
84
84
85
-
*When encrypting short texts written inwestern alphabets (mostly ASCII characters), you should account for that 255 additional overhead when defining the column size.
86
-
*When encrypting short texts written in non-western alphabets, such as Cyrillic, you should multiply the column size by 4. Notice that the storage overhead is 255 bytes at most.
85
+
*When encrypting short texts written inWestern alphabets (mostly ASCII characters), you should account for that 255 additional overhead when defining the column size.
86
+
*When encrypting short texts written in non-Western alphabets, such as Cyrillic, you should multiply the column size by 4. Notice that the storage overhead is 255 bytes at most.
87
87
*When encrypting long texts, you can ignore column size concerns.
88
88
89
89
Someexamples:
@@ -147,7 +147,7 @@ To encrypt Action Text fixtures, you should place them in `fixtures/action_text/
147
147
148
148
`active_record.encryption` will serialize values using the underlying type before encrypting them, but, unlessusing a custom `message_serializer`, *they must be serializable as strings*. Structured types like `serialized` are supported out of the box.
149
149
150
-
If you need to support a custom type, the recommended way is using a [serialized attribute](https://api.rubyonrails.org/classes/ActiveRecord/AttributeMethods/Serialization/ClassMethods.html). The declaration of the serialized attribute should go **before** the encryption declaration:
150
+
If you need to support a custom type, the recommended way is to use a [serialized attribute](https://api.rubyonrails.org/classes/ActiveRecord/AttributeMethods/Serialization/ClassMethods.html). The declaration of the serialized attribute should go **before** the encryption declaration:
151
151
152
152
```ruby
153
153
# CORRECT
@@ -188,7 +188,7 @@ end
188
188
To ease migrations of unencrypted data, the library includes the option `config.active_record.encryption.support_unencrypted_data`. When set to `true`:
189
189
190
190
*Trying to read encrypted attributes that are not encrypted will work normally, without raising any error.
191
-
*Queries with deterministically-encrypted attributes will include the "clear text" version of them to support finding both encrypted and unencrypted content. You need to set `config.active_record.encryption.extend_queries = true` to enable this.
191
+
*Queries with deterministicallyencrypted attributes will include the "clear text" version of them to support finding both encrypted and unencrypted content. You need to set `config.active_record.encryption.extend_queries = true` to enable this.
192
192
193
193
**This option is meant to be used during transition periods**while clear data and encrypted data must coexist. Both are set to `false` by default, which is the recommended goal for any application: errors will be raised when working with unencrypted data.
194
194
@@ -208,7 +208,7 @@ You can configure previous encryption schemes:
208
208
209
209
#### Global Previous Encryption Schemes
210
210
211
-
You can add previous encryption schemes by adding them as list of properties using the `previous` config property in your `application.rb`:
211
+
You can add previous encryption schemes by adding them as a list of properties using the `previous` config property in your `application.rb`:
@@ -254,7 +254,7 @@ NOTE: If you want to ignore case, make sure to use `downcase:` or `ignore_case:`
254
254
255
255
#### Unique Indexes
256
256
257
-
To support unique indexes on deterministically-encrypted columns, you need to ensure their ciphertext doesn't ever change.
257
+
To support unique indexes on deterministicallyencrypted columns, you need to ensure their ciphertext doesn't ever change.
258
258
259
259
To encourage this, deterministic attributes will always use the oldest available encryption scheme by default when multiple encryption schemes are configured. Otherwise, it's your job to ensure encryption properties don't change for these attributes, or the unique indexes won't work.
260
260
@@ -266,7 +266,7 @@ end
266
266
267
267
### Filtering Params Named as Encrypted Columns
268
268
269
-
By default, encrypted columns are configured to be [automatically filtered inRails logs](action_controller_overview.html#parameters-filtering). You can disable this behavior by adding the following to your `application.rb`:
269
+
By default, encrypted columns are configured to be [automatically filtered inRails logs](configuring.html#config-filter-parameters). You can disable this behavior by adding the following to your `application.rb`:
Supports decrypting data encrypted non-deterministically with a digest classSHA1. Default is false, which
533
+
Supports decrypting data encrypted non-deterministically with a digest classSHA1. The default is false, which
534
534
means it will only support the digest algorithm configured in`config.active_record.encryption.hash_digest_class`.
535
535
536
536
#### `config.active_record.encryption.compressor`
537
537
538
-
The compressor used to compress encrypted payloads. It should respond to `deflate`and`inflate`. Default is `Zlib`. You can find more information about compressors in the [Compression](#compression) section.
538
+
The compressor used to compress encrypted payloads. It should respond to `deflate`and`inflate`. The default is `Zlib`. You can find more information about compressors in the [Compression](#compression) section.
539
539
540
540
### Encryption Contexts
541
541
@@ -550,7 +550,7 @@ The main components of encryption contexts are:
550
550
*`key_provider`: serves encryption and decryption keys.
551
551
*`message_serializer`: serializes and deserializes encrypted payloads (`Message`).
552
552
553
-
NOTE:If you decide to build your own `message_serializer`, it's important to use safe mechanisms that can't deserialize arbitrary objects. Acommon supported scenario is encrypting existing unencrypted data. An attacker can leverage this to enter a tampered payload before encryption takes place and perform RCE attacks. This means custom serializers should avoid `Marshal`, `YAML.load` (use `YAML.safe_load` instead), or`JSON.load` (use `JSON.parse` instead).
553
+
NOTE:If you decide to build your own `message_serializer`, it's important to use safe mechanisms that can't deserialize arbitrary objects. Acommonly supported scenario is encrypting existing unencrypted data. An attacker can leverage this to enter a tampered payload before encryption takes place and perform RCE attacks. This means custom serializers should avoid `Marshal`, `YAML.load` (use `YAML.safe_load` instead), or`JSON.load` (use `JSON.parse` instead).
0 commit comments