Solid Cable can encrypt stored message payloads using Active Record Encryption.
Requirements:
- Your application must be configured to use Active Record Encryption.
- You must include the
msgpack gem (Solid Cable uses the binary MessagePack serializer by default). - Note for PostgreSQL users: Active Record Encryption does not support encrypted binary columns on PostgreSQL with Rails 7. Solid Cable will raise an error during boot if this combination is used.
Step 1: Update config/cable.yml
production:
adapter: solid_cable
encrypt: true
connects_to:
database:
writing: cable
Step 2: Configure encryption context in an initializer
Since encryption context properties contain Ruby objects, they must be set in config/initializers/solid_cable.rb rather than the YAML config:
SolidCable.configuration.encryption_context_properties = {
encryptor: ActiveRecord::Encryption::Encryptor.new,
message_serializer: ActiveRecord::Encryption::MessageSerializer.new
}
# config/initializers/solid_cable.rb
SolidCable.configuration.encryption_context_properties = {
encryptor: ActiveRecord::Encryption::Encryptor.new,
message_serializer: ActiveRecord::Encryption::MessageSerializer.new
}