appfog-vmc-plugin 0.1.6 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MTczYWIxZmFjYWY0NjBkYjU3MGJhODc0MGY3OWU3NjE3NmY1ZjFkMQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NjAxZTA3N2Q2MTg3NWU1N2U5YTdjMTdiODM4ZWU4OTNjYTgzMGNkMw==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YjI3YzEzY2E0NzljODFkZjEwYWMzNzg4NDVhMjM1ZDM0ODQ2ZmQ3MWM5M2Yz
|
10
|
+
Nzg5OWQ4ZTg3YzZmZjc5NzRhYjkzMTdjNmM3Y2NmYzY1MmJlOWI1Mzg1MWQz
|
11
|
+
N2Q3Njc3Y2MxMzQzZmEzOGYxNTRlMzQ4ZGZmZGRjYjA1NGNiY2Q=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
Mjc4OWYwMjQwMzE2NWQwNzMyMmNiMzI2ZTliNmQzNTY4N2VjZDQ5OTU4OTll
|
14
|
+
ZjJhMTkwYzdiM2NhYzZlNDFjYmZjMzVlOGYxYTE0MDRmYTk0OTZiOTRkZDEz
|
15
|
+
YWU1ODY1OTkxYjhkMjViMWY3MjkwNjBjZmIzMDk4MTg0NzU1MDI=
|
@@ -23,23 +23,15 @@ module CFoundry
|
|
23
23
|
|
24
24
|
module LoginHelpers
|
25
25
|
def login_prompts
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
:username => %w[text Email],
|
31
|
-
:password => %w[password Password]
|
32
|
-
}
|
33
|
-
end
|
26
|
+
{
|
27
|
+
:username => %w[text Email],
|
28
|
+
:password => %w[password Password]
|
29
|
+
}
|
34
30
|
end
|
35
31
|
|
36
32
|
def login(username, password)
|
37
33
|
token =
|
38
|
-
|
39
|
-
AuthToken.from_uaa_token_info(@base.uaa.authorize(username, password))
|
40
|
-
else
|
41
|
-
AuthToken.from_cc_token(@base.create_token({:password => password}, username)[:token])
|
42
|
-
end
|
34
|
+
AuthToken.from_cc_token(@base.create_token({:password => password}, username)[:token])
|
43
35
|
|
44
36
|
@base.token = token
|
45
37
|
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
require "vmc/cli/start/base"
|
2
|
+
require "vmc/cli/start/target_interactions"
|
3
|
+
|
4
|
+
module VMC::Start
|
5
|
+
class Login < Base
|
6
|
+
desc "Authenticate with the target"
|
7
|
+
group :start
|
8
|
+
input :username, :value => :email, :desc => "Account email",
|
9
|
+
:alias => "--email", :argument => :optional
|
10
|
+
input :password, :desc => "Account password"
|
11
|
+
input :organization, :desc => "Organization" , :aliases => %w{--org -o},
|
12
|
+
:from_given => by_name(:organization)
|
13
|
+
input :space, :desc => "Space", :alias => "-s",
|
14
|
+
:from_given => by_name(:space)
|
15
|
+
interactions TargetInteractions
|
16
|
+
def login
|
17
|
+
show_context
|
18
|
+
|
19
|
+
credentials =
|
20
|
+
{ :username => input[:username],
|
21
|
+
:password => input[:password]
|
22
|
+
}
|
23
|
+
|
24
|
+
prompts = client.login_prompts
|
25
|
+
|
26
|
+
# ask username first
|
27
|
+
if prompts.key? :username
|
28
|
+
type, label = prompts.delete :username
|
29
|
+
credentials[:username] ||= ask_prompt(type, label)
|
30
|
+
end
|
31
|
+
|
32
|
+
info = target_info
|
33
|
+
|
34
|
+
auth_token = nil
|
35
|
+
authenticated = false
|
36
|
+
failed = false
|
37
|
+
remaining_attempts = 3
|
38
|
+
until authenticated || remaining_attempts <= 0
|
39
|
+
remaining_attempts -= 1
|
40
|
+
unless force?
|
41
|
+
ask_prompts(credentials, prompts)
|
42
|
+
end
|
43
|
+
|
44
|
+
with_progress("Authenticating") do |s|
|
45
|
+
begin
|
46
|
+
auth_token = client.login(credentials[:username], credentials[:password])
|
47
|
+
authenticated = true
|
48
|
+
rescue CFoundry::Denied, CFoundry::Forbidden
|
49
|
+
return if force?
|
50
|
+
|
51
|
+
s.fail do
|
52
|
+
failed = true
|
53
|
+
credentials.delete(:password)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
if authenticated
|
60
|
+
info.merge!(auth_token.to_hash)
|
61
|
+
save_target_info(info)
|
62
|
+
invalidate_client
|
63
|
+
|
64
|
+
if v2?
|
65
|
+
line if input.interactive?(:organization) || input.interactive?(:space)
|
66
|
+
select_org_and_space(input, info)
|
67
|
+
end
|
68
|
+
|
69
|
+
save_target_info(info)
|
70
|
+
end
|
71
|
+
ensure
|
72
|
+
exit_status 1 if not authenticated
|
73
|
+
end
|
74
|
+
|
75
|
+
private
|
76
|
+
|
77
|
+
def ask_prompts(credentials, prompts)
|
78
|
+
prompts.each do |name, meta|
|
79
|
+
type, label = meta
|
80
|
+
credentials[name] ||= ask_prompt(type, label)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def ask_prompt(type, label)
|
85
|
+
if type == "password"
|
86
|
+
options = { :echo => "*", :forget => true }
|
87
|
+
else
|
88
|
+
options = {}
|
89
|
+
end
|
90
|
+
|
91
|
+
ask(label, options)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: appfog-vmc-plugin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tim Santeford
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-03-
|
12
|
+
date: 2013-03-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: cfoundry
|
@@ -17,14 +17,14 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - ~>
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: 0.5.
|
20
|
+
version: 0.5.2
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
25
|
- - ~>
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version: 0.5.
|
27
|
+
version: 0.5.2
|
28
28
|
description: ! "\n AppFog specific plugins for the AF CLI\n "
|
29
29
|
email:
|
30
30
|
- support@appfog.com
|
@@ -62,6 +62,8 @@ files:
|
|
62
62
|
- lib/appfog-vmc-plugin/version.rb
|
63
63
|
- lib/appfog-vmc-plugin/vmc/app/apps.rb
|
64
64
|
- lib/appfog-vmc-plugin/vmc/app/instances.rb
|
65
|
+
- lib/appfog-vmc-plugin/vmc/start/login.rb
|
66
|
+
- lib/appfog-vmc-plugin/vmc/user/base.rb
|
65
67
|
- lib/appfog-vmc-plugin/vmc.rb
|
66
68
|
homepage: http://www.appfog.com/
|
67
69
|
licenses: []
|