-
Notifications
You must be signed in to change notification settings - Fork 623
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use Vault transit engine for storing Wallet & PaymentAddress sensitive data #2310
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-
I advice to use
vault_lazy_decrypt!
-
Could we add some specs
Gemfile
Outdated
@@ -55,6 +55,7 @@ gem 'peatio', '~> 0.6.1' | |||
gem 'rack-cors', '~> 1.0.2', require: false | |||
gem 'env-tweaks', '~> 1.0.0' | |||
gem 'vault', '~> 0.12', require: false | |||
gem 'vault-rails', '~> 0.5.0', git: 'http://github.com/dnfd/vault-rails' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ask owner if they are going to merge it soon
Otherwise we will probably fork it to rubykube
Also could you check pls that patch you applied on top of master doesn't contain vulnerabilities
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
app/models/wallet.rb
Outdated
end | ||
|
||
define_method "#{accessor}=".to_sym do |value| | ||
self.settings = self.settings.merge({ accessor.to_s => value }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you could use .merge!
and avoid hash in params
self.setting.merge!(attribute => value)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer self.settings=
, it is a method call actually, while merge!
modifies a hash returned with settings
, and it breaks some specs
db/migrate/20190807092706_add_encrypted_secret_to_payment_address.rb
Outdated
Show resolved
Hide resolved
@@ -0,0 +1,12 @@ | |||
class AddEncryptedSecretToPaymentAddress < ActiveRecord::Migration[5.2] | |||
def change |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-
Put columns before timestamps
-
What is the string limit for encrypted attribute ? May be default string(255) is too many or we need more for wallet settings which is actually a long string
-
You can't just remove column you need to transfer existing data to vault before
78ffc98
to
87e7dd9
Compare
app/models/wallet.rb
Outdated
end | ||
|
||
define_method "#{attribute}=".to_sym do |value| | ||
update(settings: self.settings.merge(attribute.to_s => value)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update
will save record in db ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added specs 🙂
app/models/wallet.rb
Outdated
# We use this attribute values rules for wallet kinds: | ||
# 1** - for deposit wallets. | ||
# 2** - for fee wallets. | ||
# 3** - for withdraw wallets (sorted by security hot < warm < cold). | ||
ENUMERIZED_KINDS = { deposit: 100, fee: 200, hot: 310, warm: 320, cold: 330 }.freeze | ||
enumerize :kind, in: ENUMERIZED_KINDS, scope: true | ||
|
||
# temporary solution |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Start comment from capital letter and end with dot
87e7dd9
to
b8127f3
Compare
config/initializers/vault.rb
Outdated
|
||
Vault.configure do |config| | ||
config.address = ENV.fetch('VAULT_URL', 'http://127.0.0.1:8200') | ||
config.token = ENV.fetch('VAULT_TOKEN') | ||
config.ssl_verify = false | ||
config.timeout = 60 | ||
config.application = 'peatio' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe fetch from ENV?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes we will do
31b5c73
to
e303bf3
Compare
* Update migration
e303bf3
to
d5d5a30
Compare
It seems like |
No description provided.