I got it working via a plugin, but I’m not sure I’m fully happy with that. This is how it looks:
class SecretNotes < ::ROM::Relation[:sql]
schema(:secret_notes, infer: true) do
use :encrypted_attributes, primary_key: ENV["ENCRYPTION_PRIMARY_KEY"],
key_derivation_salt: ENV["ENCRYPTION_KEY_DERIVATION_SALT"]
encrypt :content, :title
end
end
What I don’t like here is that I’d have to pass primary key and key derivation salt every time I want to use encryption in a schema. This does not sound like a good developer experience. Is there, perhaps, a way to set something like a plugin global setting, which would be taken as a default if the configuration is not provided via use DSL?