-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
This basically means migrating a column from unencrypted to encrypted, and vice versa.
It would be invaluable for a project to be able to safely encrypt data from existing columns that are not yet encrypted, or to be able to e.g. declassify data. This feature would seem like a natural step.
In terms of zero-downtime, it means supporting things like:
class User < ActiveRecord::Base
attr_transcryptor :ssn,
old: {
key: proc { |user|
ENV['OLD_USER_SSN_ENC_KEY'] || ENV['USER_SSN_ENC_KEY']
},
mode: :per_attribute_iv,
algorithm: 'aes-256-gcm'
},
new: {}
# ...
end^ Read from the old column, but write to both old and new columns. The new column (e.g. ssn) is written _un_encrypted.
class User < ActiveRecord::Base
attr_transcryptor :ssn,
new: {
key: proc { |user|
ENV['OLD_USER_SSN_ENC_KEY'] || ENV['USER_SSN_ENC_KEY']
},
mode: :per_attribute_iv,
algorithm: 'aes-256-gcm'
},
old: {}
# ...
end^ As above, but the new column (e.g. encrypted_ssn) is written _en_crypted.
And from a Migration's perspective, it means something like:
# Encrypt column
re_encrypt_column(
:my_table,
:column_1,
{},
{ key: '2asd2asd2asd2asd2asd2asd2asd2asd' }
) # Decrypt column
re_encrypt_column(
:my_table,
:column_1,
{ key: '2asd2asd2asd2asd2asd2asd2asd2asd' },
{}
)Reactions are currently unavailable