Skip to content

Commit 5a343ad

Browse files
committed
Use lockbox for credential encryption
1 parent 2db557a commit 5a343ad

10 files changed

+33
-70
lines changed

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ gem 'typhoeus'
3838
gem "mongo", "~> 2"
3939
gem 'aws-sdk', '~> 3'
4040
gem 'kaminari'
41+
gem 'lockbox'
4142

4243
group :development, :test do
4344
# Call 'byebug' anywhere in the code to stop execution and get a debugger console

Gemfile.lock

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1238,6 +1238,7 @@ GEM
12381238
listen (3.5.1)
12391239
rb-fsevent (~> 0.10, >= 0.10.3)
12401240
rb-inotify (~> 0.9, >= 0.9.10)
1241+
lockbox (0.6.4)
12411242
lograge (0.11.2)
12421243
actionpack (>= 4)
12431244
activesupport (>= 4)
@@ -1375,6 +1376,7 @@ DEPENDENCIES
13751376
jwt
13761377
kaminari
13771378
listen (~> 3.3)
1379+
lockbox
13781380
lograge
13791381
mongo (~> 2)
13801382
mysql2

app/models/credential.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
class Credential < ApplicationRecord
2-
include Encryptable
3-
4-
attr_encrypted :value
2+
encrypts :value
53
end

app/models/data_source_user_oauth2.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
class DataSourceUserOauth2 < ApplicationRecord
2-
include Encryptable
3-
42
belongs_to :user
53
belongs_to :data_source
64

7-
attr_encrypted :options
5+
encrypts :options
86
end

app/services/encryption_service.rb

Lines changed: 0 additions & 26 deletions
This file was deleted.

config/initializers/lockbox.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Lockbox.master_key = ENV.fetch('LOCKBOX_MASTER_KEY')
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class AddCipherTextToCredentials < ActiveRecord::Migration[6.1]
2+
def change
3+
add_column :credentials, :value_ciphertext, :text
4+
end
5+
end
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class AddCipherTextToDataSourceUserOauth2 < ActiveRecord::Migration[6.1]
2+
def change
3+
add_column :data_source_user_oauth2s, :options_ciphertext, :text
4+
end
5+
end

db/schema.rb

Lines changed: 17 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/encryptable.rb

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)