Reputation: 3174
I'm trying to encrypt two columns on my User
model in Ruby on Rails. I have already successfully encrypted 6 other columns on a different table but this time I am getting the error must specify an iv
only on the User
table.
I am using the devise gem for authentication.
Here is my original migration to add the columns:
class AddPushNotificationColumnsToUser < ActiveRecord::Migration[5.1]
def change
add_column :users, :endpoint, :string
add_column :users, :expiration_time, :string
add_column :users, :encrypted_p256dh, :string
add_column :users, :encrypted_auth, :string
add_column :users, :encrypted_p256dh_iv, :string
add_column :users, :encrypted_auth_iv, :string
end
end
My Model:
attr_encrypted :p256dh, key: Rails.application.secrets.db_encryption_key
attr_encrypted :auth, key: Rails.application.secrets.db_encryption_key
When I call User.first.p256dh
or User.first.auth
I get the error:must specify an iv
Any help would be appreciated.
Upvotes: 2
Views: 1359