Save username and password to a Normariffic yaml file
This commit is contained in:
@@ -2,6 +2,7 @@ require 'zanzibar/version'
|
||||
require 'savon'
|
||||
require 'io/console'
|
||||
require 'fileutils'
|
||||
require 'yaml'
|
||||
|
||||
module Zanzibar
|
||||
##
|
||||
@@ -124,9 +125,11 @@ module Zanzibar
|
||||
end
|
||||
|
||||
## Get the password, save it to a file, and return the path to the file.
|
||||
def get_password_and_save(scrt_id, path, name)
|
||||
password = get_password(scrt_id)
|
||||
save_password_to_file(password, path, name)
|
||||
def get_username_and_password_and_save(scrt_id, path, name)
|
||||
secret_items = get_secret(scrt_id)[:secret][:items][:secret_item]
|
||||
password = get_secret_item_by_field_name(secret_items, 'Password')[:value]
|
||||
username = get_secret_item_by_field_name(secret_items, 'Username')[:value]
|
||||
save_username_and_password_to_file(password, username, path, name)
|
||||
return File.join(path, name)
|
||||
end
|
||||
|
||||
@@ -137,9 +140,10 @@ module Zanzibar
|
||||
end
|
||||
|
||||
## Write the password to a file. Intended for use with a Zanzifile
|
||||
def save_password_to_file(password, path, name)
|
||||
def save_username_and_password_to_file(password, username, path, name)
|
||||
user_pass = {'username' => username.to_s, 'password' => password.to_s}.to_yaml
|
||||
File.open(File.join(path, name), 'wb') do |file|
|
||||
file.print password
|
||||
file.print user_pass
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user