Skip to content

Commit

Permalink
Merge pull request #19006 from carbonin/encrypt_cred_queue_params
Browse files Browse the repository at this point in the history
Encrypt passwords before putting them on the queue as args
  • Loading branch information
Fryguy authored Jul 18, 2019
2 parents 712d9cd + 5656323 commit a4dd59f
Show file tree
Hide file tree
Showing 3 changed files with 237 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,18 @@ def self.raw_create_in_provider(manager, params)
create!(create_params)
end

def self.password_attribute_keys
self::API_ATTRIBUTES.map do |k, v|
k if v[:type] == :password
end.compact
end

def self.encrypt_queue_params(params)
encrypted_params = params.slice(*password_attribute_keys)
encrypted_params.transform_values! { |v| ManageIQ::Password.try_encrypt(v) }
params.merge(encrypted_params)
end

def raw_update_in_provider(params)
update!(self.class.params_to_attributes(params.except(:task_id, :miq_task_id)))
end
Expand Down
12 changes: 10 additions & 2 deletions app/models/manageiq/providers/embedded_ansible/crud_common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,15 @@ def create_in_provider(manager_id, params)
end
end

def encrypt_queue_params(params)
params
end

def create_in_provider_queue(manager_id, params, auth_user = nil)
manager = parent.find(manager_id)
action = "Creating #{self::FRIENDLY_NAME}"
action << " (name=#{params[:name]})" if params[:name]
queue(manager.my_zone, nil, "create_in_provider", [manager_id, params], action, auth_user)
queue(manager.my_zone, nil, "create_in_provider", [manager_id, encrypt_queue_params(params)], action, auth_user)
end

private
Expand Down Expand Up @@ -84,8 +88,12 @@ def update_in_provider(params)
self
end

def encrypt_queue_params(params)
self.class.encrypt_queue_params(params)
end

def update_in_provider_queue(params, auth_user = nil)
queue("update_in_provider", [params], "Updating", auth_user)
queue("update_in_provider", [encrypt_queue_params(params)], "Updating", auth_user)
end

def raw_delete_in_provider
Expand Down
Loading

0 comments on commit a4dd59f

Please sign in to comment.