README.md in lockbox-1.1.2 vs README.md in lockbox-1.2.0
- old
+ new
@@ -115,10 +115,11 @@
has_encrypted :signed_at, type: :datetime
has_encrypted :opens_at, type: :time
has_encrypted :active, type: :boolean
has_encrypted :salary, type: :integer
has_encrypted :latitude, type: :float
+ has_encrypted :longitude, type: :decimal
has_encrypted :video, type: :binary
has_encrypted :properties, type: :json
has_encrypted :settings, type: :hash
has_encrypted :messages, type: :array
has_encrypted :ip, type: :inet
@@ -564,95 +565,61 @@
## Key Rotation
To make key rotation easy, you can pass previous versions of keys that can decrypt.
-### Active Record & Mongoid
+Create `config/initializers/lockbox.rb` with:
-Update your model:
-
```ruby
-class User < ApplicationRecord
- has_encrypted :email, previous_versions: [{master_key: previous_key}]
-end
+Lockbox.default_options[:previous_versions] = [{master_key: previous_key}]
```
-To rotate existing records, use:
+To rotate existing Active Record & Mongoid records, use:
```ruby
Lockbox.rotate(User, attributes: [:email])
```
-Once all records are rotated, you can remove `previous_versions` from the model.
+To rotate existing Action Text records, use:
-### Action Text
-
-Update your initializer:
-
```ruby
-Lockbox.encrypts_action_text_body(previous_versions: [{master_key: previous_key}])
-```
-
-To rotate existing records, use:
-
-```ruby
Lockbox.rotate(ActionText::RichText, attributes: [:body])
```
-Once all records are rotated, you can remove `previous_versions` from the initializer.
+To rotate existing Active Storage files, use:
-### Active Storage
-
-Update your model:
-
```ruby
-class User < ApplicationRecord
- encrypts_attached :license, previous_versions: [{master_key: previous_key}]
-end
-```
-
-To rotate existing files, use:
-
-```ruby
User.with_attached_license.find_each do |user|
user.license.rotate_encryption!
end
```
-Once all files are rotated, you can remove `previous_versions` from the model.
+To rotate existing CarrierWave files, use:
-### CarrierWave
-
-Update your model:
-
```ruby
-class LicenseUploader < CarrierWave::Uploader::Base
- encrypt previous_versions: [{master_key: previous_key}]
-end
-```
-
-To rotate existing files, use:
-
-```ruby
User.find_each do |user|
user.license.rotate_encryption!
+ # or for multiple files
+ user.licenses.map(&:rotate_encryption!)
end
```
-For multiple files, use:
+Once everything is rotated, you can remove `previous_versions` from the initializer.
+### Individual Fields & Files
+
+You can also pass previous versions to individual fields and files.
+
```ruby
-User.find_each do |user|
- user.licenses.map(&:rotate_encryption!)
+class User < ApplicationRecord
+ has_encrypted :email, previous_versions: [{master_key: previous_key}]
end
```
-Once all files are rotated, you can remove `previous_versions` from the model.
-
### Local Files & Strings
-For local files and strings, use:
+To rotate local files and strings, use:
```ruby
Lockbox.new(key: key, previous_versions: [{key: previous_key}])
```
@@ -944,9 +911,15 @@
```ruby
class User < ApplicationRecord
has_encrypted :email, encode: false
end
+```
+
+or set it globally:
+
+```ruby
+Lockbox.encode_attributes = false
```
## Compatibility
It’s easy to read encrypted data in another language if needed.