ankane / mailkick

Email subscriptions for Rails
MIT License
915 stars 76 forks source link

Support for Lockbox? #54

Closed chuckphillips closed 4 years ago

chuckphillips commented 4 years ago

Any plans to support lockbox encryption of the email column in the mailkick_opt_outs table?

ankane commented 4 years ago

Hey @chuckphillips, I think you can add the necessary columns and create an initializer with:

Mailkick::OptOut.encrypts :email
Mailkick::OptOut.blind_index :email

(and follow the typically pattern for migrating columns if needed)

This line will need to be changed to use Active Record to generate email condition - something like WHERE EXISTS(#{Mailkick::OptOut.where(email: email, ...).to_sql}) - so it'll use the blind index when one exists or the normal column otherwise. Actually, looks like that's a join so it won't be as straightforward - both email columns would need to have a blind index and use the same key.

https://github.com/ankane/mailkick/blob/4dad73629bfdc0d7c86a17276cfa6f9682ba444b/lib/mailkick/model.rb#L14

Let me know if you have any luck with it.

ankane commented 4 years ago

Cleaning up issues

xdmx commented 4 years ago

I just wanted to say that native support to Lockbox would be awesome :pray:

ankane commented 3 years ago

Just fyi: Just pushed Mailkick 1.0, which no longer stores emails (it just references models). This should be better for privacy.