Class: Pandoru::SecretStore::Adapters::MacOS
- Defined in:
- lib/pandoru/secret_store.rb
Overview
macOS Keychain via ‘security`. Account is fixed to the service name; the secret blob is the password slot.
Instance Method Summary collapse
- #available? ⇒ Boolean
- #delete(service) ⇒ Object
- #name ⇒ Object
- #read(service) ⇒ Object
- #write(service, secret) ⇒ Object
Methods inherited from Base
Constructor Details
This class inherits a constructor from Pandoru::SecretStore::Adapters::Base
Instance Method Details
#available? ⇒ Boolean
104 105 106 |
# File 'lib/pandoru/secret_store.rb', line 104 def available? RUBY_PLATFORM.include?('darwin') && which?('security') end |
#delete(service) ⇒ Object
120 121 122 123 |
# File 'lib/pandoru/secret_store.rb', line 120 def delete(service) _out, ok = run(['security', 'delete-generic-password', '-s', service]) ok end |
#name ⇒ Object
102 |
# File 'lib/pandoru/secret_store.rb', line 102 def name = 'macOS Keychain' |
#read(service) ⇒ Object
108 109 110 111 |
# File 'lib/pandoru/secret_store.rb', line 108 def read(service) out, ok = run(['security', 'find-generic-password', '-s', service, '-w']) ok ? out.chomp : nil end |
#write(service, secret) ⇒ Object
113 114 115 116 117 118 |
# File 'lib/pandoru/secret_store.rb', line 113 def write(service, secret) _out, ok = run(['security', 'add-generic-password', '-U', '-s', service, '-a', service, '-w', secret, '-D', 'application password', '-l', service]) ok end |