Skip to content

Commit

Permalink
add active record encryption
Browse files Browse the repository at this point in the history
  • Loading branch information
yshmarov committed Mar 19, 2023
1 parent 94f48ae commit 75ece9c
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 3 deletions.
3 changes: 3 additions & 0 deletions app/models/client.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
class Client < ApplicationRecord
encrypts :name, deterministic: true
encrypts :health_condition
encrypts :annual_income
end
1 change: 1 addition & 0 deletions app/views/clients/_client.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<p>
<strong>Name:</strong>
<%= client.name %>
<%= client.ciphertext_for :name %>
</p>

<p>
Expand Down
2 changes: 2 additions & 0 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 7.0

config.active_record.encryption.support_unencrypted_data = true
config.active_record.encryption.extend_queries = true
# Configuration for the application, engines, and railties goes here.
#
# These settings can be overridden in specific environments using the files
Expand Down
2 changes: 1 addition & 1 deletion config/credentials.yml.enc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
fZy6LSDVRE8iZS5lX4NcYle3bXFvBJO3imQBtD5YU2Amx4E0hZuBVLU2YRUKZ80ZHp3+crFC0uNDJKmtclmeKla7QCZK1BWvcuvZkPNATktgtQDe5qKgi2ttGv4p/pKsEVKLY5YniRMochZTzure+J7pqEHpShtLyljDVXAlmCQsZOnyVnR5yRP4EECiiYnpTefOHsSvl+w+73NP8s0PfD8p7xLLUWIWR0DR/JlFyfQzK8HDW+cOnSR6/5ddKG4XO+Pd54Dq5vL76NhFmDyCHVh5l4f4tNhQfV0XIRXBfludEgjbbBZs6xE9vNYWQfHcPr7T4wANoE2DS6KTMw5Srq9Nj28SKlwCwLEZLvsc8JycHgVkwdf54FU8ydZ5Pb3g3WMokb7td76W3AM0bl411WxIeZhF6he+1+fC--oqitYbagkYJ1waVI--Gco80PJxPLgWpdt/Z1boiQ==
et2BLrocXIatQvM9ZPMzpPdm5LG5KzZN1K4poIjOTxQtvfU0La7/A4Aq18Z+WKu0dxH4aDelglc6LLizincg7LGSbhSR9ao6eGPf764pk+gJDiB0McubKIWADaKHUSKV05i2XI0V9Lf8bpXkUwHL62hs2kIv3CeIM9YWDQAGYJ7ETXud/wUL9ELUMpkc3WyWbAtvPXSw59ccnZm2EpzGTDyb3bUsh1bCHRru1gFgyTOtfKhG4yeohLSNZRQJAJSuWaZVQST/+0EQheIKQnrW+FYo5ttZNPVdYFp/G/3dOu02xm0cc29SnzsydHofgLweO2ABtdrhrN1sZX9ZofDe/rRonDsryZsSNKgKFvneJk6ez+IElHv+UApD0tstqNTdOnNSzvXTacuUlfNTgu7G/ltrPthK2UtvWinJp9lilwPexLIXLMt8XsKvL2jLqHon+/lzbm5nALZKQNqyHMQOKCoUzNw4rqdXtiFM+kK2MkK8XB6vcJG0PCYW7a64qvWLQpFnxgElto94dQoiC+lygtKbL8uSGZzXqYYFF0JD6tEHRsp0dncCnoKMF3o4UxZTyK+DrO2uinzoVSa0q1rWHE6j6R6qiX3fIZDoa1LGTYeUeT4K2Bs+XYduDEPB7s0bJBiqhvbobbTU8JOkMQ==--pYSRelv75gXQgLvS--9uLOJHkFc840xJnM6WvTqA==
5 changes: 5 additions & 0 deletions db/migrate/20230319211327_encrypt_integer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class EncryptInteger < ActiveRecord::Migration[7.0]
def change
change_column :clients, :annual_income, :text
end
end
4 changes: 2 additions & 2 deletions db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 75ece9c

Please sign in to comment.