README.md in lockbox-0.6.1 vs README.md in lockbox-0.6.2
- old
+ new
@@ -25,11 +25,11 @@
```ruby
Lockbox.generate_key
```
-Store the key with your other secrets. This is typically Rails credentials or an environment variable ([dotenv](https://github.com/bkeepers/dotenv) is great for this). Be sure to use different keys in development and production. Keys don’t need to be hex-encoded, but it’s often easier to store them this way.
+Store the key with your other secrets. This is typically Rails credentials or an environment variable ([dotenv](https://github.com/bkeepers/dotenv) is great for this). Be sure to use different keys in development and production.
Set the following environment variable with your key (you can use this one in development)
```sh
LOCKBOX_MASTER_KEY=0000000000000000000000000000000000000000000000000000000000000000
@@ -119,10 +119,11 @@
encrypts :latitude, type: :float
encrypts :video, type: :binary
encrypts :properties, type: :json
encrypts :settings, type: :hash
encrypts :messages, type: :array
+ encrypts :ip, type: :inet
end
```
**Note:** Use a `text` column for the ciphertext in migrations, regardless of the type
@@ -1084,15 +1085,32 @@
end
```
## Upgrading
+### 0.6.0
+
+0.6.0 adds `encrypted: true` to Active Storage metadata for new files. This field is informational, but if you prefer to add it to existing files, use:
+
+```ruby
+User.with_attached_license.find_each do |user|
+ next unless user.license.attached?
+
+ metadata = user.license.metadata
+ unless metadata["encrypted"]
+ user.license.blob.update!(metadata: metadata.merge("encrypted" => true))
+ end
+end
+```
+
### 0.3.6
0.3.6 makes content type detection more reliable for Active Storage. You can check and update the content type of existing files with:
```ruby
-User.find_each do |user|
+User.with_attached_license.find_each do |user|
+ next unless user.license.attached?
+
license = user.license
content_type = Marcel::MimeType.for(license.download, name: license.filename.to_s)
if content_type != license.content_type
license.update!(content_type: content_type)
end