Sha256: f6c487c2286bcf4896f3cc0ce4ef75447cae7e10b8548511d039790e00506dcf
Contents?: true
Size: 1.15 KB
Versions: 1
Compression:
Stored size: 1.15 KB
Contents
module Omnivault class AppleKeychain < AbstractVault def initialize # Need to require within initializer, to avoid LoadError on # non-Apple platforms require 'keychain' require 'aws-keychain-util/credential_provider' end def entries keychain = open_or_create_keychain Hash[keychain.generic_passwords.all.map do |item| [item.label, item.password] end] end def fetch(key) entries[key] end def store(key, value) keychain = open_or_create_keychain if (entry = keychain.generic_passwords.where(label: key).all.first) entry.password = value else keychain.generic_passwords.create( service: key, label: key, password: value ) end end def configure_aws! provider = ::AwsKeychainUtil::CredentialProvider.new('default', 'aws') AWS.config(credential_provider: provider) end private def open_or_create_keychain(name = 'aptible-cookbook') keychain = Keychain.open("#{name}.keychain") return keychain if keychain.exists? Keychain.create("#{name}.keychain") end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
omnivault-0.1.0 | lib/omnivault/apple_keychain.rb |