establish 0.0.22 → 0.0.23

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 56fb735050c9180935b7240f2dc5c9df0361dd4a401375050385c5907d44ab22
4
- data.tar.gz: 84f69a19579d76a71cb17edf51721354d3535655df2691abbc62cfba56346485
3
+ metadata.gz: 67cc578f9c2613d233891e81ab3b66c0d2bffeb03c406b5e0c8ae0ae3359bef9
4
+ data.tar.gz: 496168e5fab860f3778b5a5abb982eedcd7002c435ade237088b4060187fa57f
5
5
  SHA512:
6
- metadata.gz: b98147df552d896c5e3bf872136c1fa12f82afe7c3db4e05e04e6dfd22233b2f2b9619b0eb2dfff5bb49f2549593909f8d007496fb70915a7f3f17ea47643489
7
- data.tar.gz: 220f3049b1792f88663f39c1974d3db7772df7464d716108ed65b833752e6a2fcf9a230e99ff15491ec664cb6411ab9881ef0f4f12a78e8dfa0793e92f1f1178
6
+ metadata.gz: 475a202295cbd697b06d5eeec012328961443285b0e3be93f0936aa149c2656f14ac994376a9b4c349cc1ff6ada39ea64271d8d45dc923c4ef7dcf192c5c135b
7
+ data.tar.gz: 78bbb82503f934a91b65dc2270006ab27de004880718e2a6e45807e4f2db85f7039941122b92712b34c28c1903ab7878a8a2c728fb1d8732ab9a2e9a4f1024c6
@@ -1,4 +1,5 @@
1
1
  require 'security'
2
+ require 'highline/import' # to hide the entered password
2
3
 
3
4
  module Establish
4
5
  class PasswordManager
@@ -11,8 +12,33 @@ module Establish
11
12
  self.username ||= ENV["ESTABLISH_USER"] || self.load_from_keychain[0]
12
13
  self.password ||= ENV["ESTABLISH_PASSWORD"] || self.load_from_keychain[1]
13
14
 
15
+ if (self.username || '').length == 0 or (self.password || '').length == 0
16
+ ask_for_login
17
+ end
14
18
  end
15
19
 
20
+ def ask_for_login
21
+ puts "No username or password given. You can use environment variables"
22
+ puts "ESTABLISH_USER, ESTABLISH_PASSWORD"
23
+ puts "The login information will be stored in your keychain"
24
+
25
+ while (self.username || '').length == 0
26
+ self.username = ask("Username: ")
27
+ end
28
+
29
+ while (self.password || '').length == 0
30
+ self.password = ask("Password: ") { |q| q.echo = "*" }
31
+ end
32
+
33
+ # Now we store this information in the keychain
34
+ # Example usage taken from https://github.com/nomad/cupertino/blob/master/lib/cupertino/provisioning_portal/commands/login.rb
35
+ if Security::InternetPassword.add(Establish::PasswordManager::HOST, self.username, self.password)
36
+ return true
37
+ else
38
+ Helper.log.error "Could not store password in keychain"
39
+ return false
40
+ end
41
+ end
16
42
 
17
43
  def load_from_keychain
18
44
  pass = Security::InternetPassword.find(:server => Establish::PasswordManager::HOST)
@@ -1,3 +1,3 @@
1
1
  module Establish
2
- VERSION = "0.0.22"
2
+ VERSION = "0.0.23"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: establish
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.22
4
+ version: 0.0.23
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vincenzo Fehring