-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Encrypt cache values via Solid Cache config
Allows you to enable encryption of cache values with: ```yaml \# config/solid_cache.yml production: encrypt: true ``` or ```ruby \# application.rb config.solid_cache.encrypt = true ``` Requires Active Record Encryption to be configured already. Solid Cache by default uses a custom encryptor and message serializer that are optimised for it. Firstly it disabled compression with the encryptor `ActiveRecord::Encryption::Encryptor.new(compress: false)` - the cache already compresses the data. Secondly it uses `ActiveRecord::Encryption::MessagePackMessageSerializer.new` as the serializer. This serializer can only be used for binary columns, but can store about 40% more data than the standard serializer. Or allow custom context properties to be set: ```ruby \# application.rb config.solid_cache.encryption_context_properties = { encryptor: ActiveRecord::Encryption::Encryptor.new, message_serializer: ActiveRecord::Encryption::MessageSerializer.new } ```
- Loading branch information
Showing
17 changed files
with
239 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# frozen_string_literal: true | ||
|
||
module SolidCache | ||
class Entry | ||
module Encryption | ||
extend ActiveSupport::Concern | ||
|
||
included do | ||
if SolidCache.configuration.encrypt? | ||
encrypts :value, **SolidCache.configuration.encryption_context_properties | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
KXs4HRH7tZqQZmVrP872Vy2OLbDJ3OoirCMzMrsRxDqraDWMLPB+XdNfVD9RhEDiKw05LNXPAGCIVi82dY/I4TJA2B8tz0cEX0DrfBphZ4Azo0gxjVva5xxfMcaQxa8Zv5lNtn+MXgXVOnO8FedKhrBxNFManCxaaBjZKlui9UTS/y3DeLvPjgFhSgZ6YcPQVoAU3kI08liXWUsleDFBEbaw8vJ0lKT20i5iKi/VgOyGBSju/sHW6EYUsQO6peOD8lWackcficA4I6tQ04Ce4GeYIP7KkA/tlTCwkC3oaS9Km+04J3zGfUS/9zh9apHw+C0zuoAr59+dmYNuKg3DhuTWjbI7iXjViUzGbnHRnv+qJXON4Nb3wwAjsmNgPGPqrObruzaQ10kuRCFnMgyy2GbXq/DJlZ2ZScgNItd/Z1Gcw0K0RXw6LDV+pkg8CnTYCfNJfA5NAbD/GNFv8NC9N5sJqDJoEhUfVwncbcUfX13HNqiAvO2XkxdIMzlMOVQijkT2CltmhVWYB1SRCLQv6kbd+iu/sSGcu4ropsVcxgonKkch5JsSjIXwEWCOpaDVg3Jm8RiJWP+LwjhfEC5/OSHOmFGKfIwHGSmLNvazgfx6odHnqW3ZPyTewcgYhK83ok1BS4GwX1UjDs1ZqXD3DX/W63pknqdx--lfZoS+MYEht37XUa--ICZ1nYvIPt+EI+k2Ti4pTA== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
068c2c12595c52b8593721734c34dfed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
default: &default | ||
databases: [primary_shard_one, primary_shard_two, secondary_shard_one, secondary_shard_two] | ||
encrypt: true | ||
|
||
store_options: | ||
max_age: 3600 | ||
max_size: | ||
|
||
development: | ||
<<: *default | ||
|
||
test: | ||
<<: *default |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
default: &default | ||
databases: [primary_shard_one, primary_shard_two, secondary_shard_one, secondary_shard_two] | ||
encrypt: true | ||
|
||
store_options: | ||
max_age: 3600 | ||
max_size: | ||
|
||
development: | ||
<<: *default | ||
|
||
test: | ||
<<: *default |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.