Class: RPass::VaultProvider

Inherits:
Object
  • Object
show all
Defined in:
lib/rpass/vault_provider.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(storage) ⇒ VaultProvider

Returns a new instance of VaultProvider.



14
15
16
# File 'lib/rpass/vault_provider.rb', line 14

def initialize(storage)
  @storage = storage
end

Instance Attribute Details

#storageObject (readonly)

Returns the value of attribute storage.



12
13
14
# File 'lib/rpass/vault_provider.rb', line 12

def storage
  @storage
end

Instance Method Details

#cliObject



38
39
40
# File 'lib/rpass/vault_provider.rb', line 38

def cli
  @cli ||= HighLine.new
end

#get_passwordObject



26
27
28
# File 'lib/rpass/vault_provider.rb', line 26

def get_password
  cli.ask("Enter your password: "){ |q| q.echo = false }.strip
end

#get_second_factorObject



30
31
32
# File 'lib/rpass/vault_provider.rb', line 30

def get_second_factor
  cli.ask("Enter your second factor: ").strip
end

#get_usernameObject



34
35
36
# File 'lib/rpass/vault_provider.rb', line 34

def get_username
  cli.ask("Enter your username: ").strip
end

#usernameObject



22
23
24
# File 'lib/rpass/vault_provider.rb', line 22

def username
  storage["username"] ||= get_username
end

#vaultObject



18
19
20
# File 'lib/rpass/vault_provider.rb', line 18

def vault
  LastPass::Vault.open_remote(username, get_password, get_second_factor)
end