README.md in lockbox-0.2.5 vs README.md in lockbox-0.3.0
- old
+ new
@@ -3,11 +3,11 @@
:package: Modern encryption for Rails
- Uses state-of-the-art algorithms
- Works with database fields, files, and strings
- Stores encrypted data in a single field
-- Requires you to only manage a single encryption key
+- Requires you to only manage a single encryption key (with the option to have more)
- Makes migrating existing data and key rotation easy
Learn [the principles behind it](https://ankane.org/modern-encryption-rails), [how to secure emails](https://ankane.org/securing-user-emails-lockbox), and [how to secure sensitive data in Rails](https://ankane.org/sensitive-data-rails)
[![Build Status](https://travis-ci.org/ankane/lockbox.svg?branch=master)](https://travis-ci.org/ankane/lockbox)
@@ -115,17 +115,29 @@
Lockbox automatically works with serialized fields for maximum compatibility with existing code and libraries.
```ruby
class User < ApplicationRecord
serialize :properties, JSON
- encrypts :properties
-
store :settings, accessors: [:color, :homepage]
- encrypts :settings
+ attribute :configuration, CustomType.new
+
+ encrypts :properties, :settings, :configuration
end
```
+For [StoreModel](https://github.com/DmitryTsepelev/store_model), use:
+
+```ruby
+class User < ApplicationRecord
+ encrypts :configuration, type: Configuration.to_type
+
+ after_initialize do
+ self.configuration ||= {}
+ end
+end
+```
+
#### Validations
Validations work as expected with the exception of uniqueness. Uniqueness validations require a [blind index](https://github.com/ankane/blind_index).
### Mongoid
@@ -305,10 +317,12 @@
## Key Rotation
To make key rotation easy, you can pass previous versions of keys that can decrypt.
+### Active Record
+
For Active Record, use:
```ruby
class User < ApplicationRecord
encrypts :email, previous_versions: [{key: previous_key}]
@@ -319,10 +333,28 @@
```ruby
user.update!(email: user.email)
```
+### Mongoid
+
+For Mongoid, use:
+
+```ruby
+class User
+ encrypts :email, previous_versions: [{key: previous_key}]
+end
+```
+
+To rotate, use:
+
+```ruby
+user.update!(email: user.email)
+```
+
+### Active Storage
+
For Active Storage use:
```ruby
class User < ApplicationRecord
encrypts_attached :license, previous_versions: [{key: previous_key}]
@@ -333,10 +365,12 @@
```ruby
user.license.rotate_encryption!
```
+### CarrierWave
+
For CarrierWave, use:
```ruby
class LicenseUploader < CarrierWave::Uploader::Base
encrypt previous_versions: [{key: previous_key}]
@@ -346,9 +380,11 @@
To rotate existing files, use:
```ruby
user.license.rotate_encryption!
```
+
+### Strings
For strings, use:
```ruby
Lockbox.new(key: key, previous_versions: [{key: previous_key}])