bosh_cli 1.3232.14.0 → 1.3232.24.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cli/client/credentials.rb +9 -0
- data/lib/cli/client/director.rb +19 -1
- data/lib/cli/client/uaa/token_provider.rb +22 -15
- data/lib/cli/version.rb +1 -1
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c71f4dfaeff471cb81968a20e376da09e8609cfa
|
4
|
+
data.tar.gz: 4163600dbad95ff0513dfc74ce77552b71f35599
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ddc0eebf3cea4efd3b284be7a92c48ce3153b71dd013a419addb8e290419121902ea41a128a4d1d37fd6053e08fdc8fcddc8d7d38d61eaa075a092c195d6ec39
|
7
|
+
data.tar.gz: 8d6a4f9c8121ffe0937c934dafc0ace23080749ad1dbd799fe9d45008d5534f771bcb9ecdab251ae24eaba0da13c9b454c1d3a0cb66b38753b26605cd0585610
|
@@ -13,6 +13,11 @@ module Bosh
|
|
13
13
|
def authorization_header
|
14
14
|
@token_provider.token
|
15
15
|
end
|
16
|
+
|
17
|
+
def refresh
|
18
|
+
@token_provider.refresh
|
19
|
+
true
|
20
|
+
end
|
16
21
|
end
|
17
22
|
|
18
23
|
class BasicCredentials
|
@@ -28,6 +33,10 @@ module Bosh
|
|
28
33
|
def authorization_header
|
29
34
|
'Basic ' + Base64.encode64("#{@username}:#{@password}").strip
|
30
35
|
end
|
36
|
+
|
37
|
+
def refresh
|
38
|
+
false
|
39
|
+
end
|
31
40
|
end
|
32
41
|
end
|
33
42
|
end
|
data/lib/cli/client/director.rb
CHANGED
@@ -865,14 +865,32 @@ module Bosh
|
|
865
865
|
end
|
866
866
|
|
867
867
|
if @credentials
|
868
|
+
@credentials.refresh unless payload.nil?
|
868
869
|
headers['Authorization'] = @credentials.authorization_header
|
869
870
|
end
|
870
871
|
|
871
|
-
http_client.request(method, uri, {
|
872
|
+
response = http_client.request(method, uri, {
|
872
873
|
:body => payload,
|
873
874
|
:header => headers,
|
874
875
|
}, &block)
|
875
876
|
|
877
|
+
if !response.nil? && response.code == 401
|
878
|
+
if !payload.nil?
|
879
|
+
return response
|
880
|
+
end
|
881
|
+
|
882
|
+
if @credentials.nil? || !@credentials.refresh
|
883
|
+
raise AuthError
|
884
|
+
end
|
885
|
+
|
886
|
+
headers['Authorization'] = @credentials.authorization_header
|
887
|
+
response = http_client.request(method, uri, {
|
888
|
+
:body => payload,
|
889
|
+
:header => headers,
|
890
|
+
}, &block)
|
891
|
+
end
|
892
|
+
|
893
|
+
response
|
876
894
|
rescue URI::Error,
|
877
895
|
SocketError,
|
878
896
|
Errno::ECONNREFUSED,
|
@@ -17,17 +17,22 @@ module Bosh
|
|
17
17
|
access_info.auth_header if access_info
|
18
18
|
end
|
19
19
|
|
20
|
+
def refresh
|
21
|
+
get_access_info(true)
|
22
|
+
nil
|
23
|
+
end
|
24
|
+
|
20
25
|
def username
|
21
26
|
get_access_info.username
|
22
27
|
end
|
23
28
|
|
24
29
|
private
|
25
30
|
|
26
|
-
def get_access_info
|
31
|
+
def get_access_info(force_refresh = false)
|
27
32
|
if @auth_info.client_auth?
|
28
|
-
client_access_info
|
33
|
+
client_access_info(force_refresh)
|
29
34
|
else
|
30
|
-
password_access_info
|
35
|
+
password_access_info(force_refresh)
|
31
36
|
end
|
32
37
|
end
|
33
38
|
|
@@ -35,26 +40,28 @@ module Bosh
|
|
35
40
|
@uaa_client ||= Bosh::Cli::Client::Uaa::Client.new(@target, @auth_info, @config)
|
36
41
|
end
|
37
42
|
|
38
|
-
def client_access_info
|
39
|
-
if !@
|
40
|
-
@
|
43
|
+
def client_access_info(force_refresh = false)
|
44
|
+
if !@access_info.nil? && @access_info.was_issued_for?(@auth_info.client_id)
|
45
|
+
@access_info = refresh_if_needed(@access_info, force_refresh)
|
41
46
|
else
|
42
|
-
@
|
47
|
+
@access_info = uaa_client.access_info({})
|
43
48
|
end
|
44
49
|
end
|
45
50
|
|
46
|
-
def password_access_info
|
47
|
-
|
48
|
-
|
51
|
+
def password_access_info(force_refresh = false)
|
52
|
+
if @access_info.nil?
|
53
|
+
config_access_token = @config.access_token(@target)
|
54
|
+
return nil unless config_access_token
|
49
55
|
|
50
|
-
|
51
|
-
|
56
|
+
@access_info = PasswordAccessInfo.create(config_access_token, @config.refresh_token(@target), @token_decoder)
|
57
|
+
return nil unless @access_info
|
58
|
+
end
|
52
59
|
|
53
|
-
refresh_if_needed(access_info)
|
60
|
+
@access_info = refresh_if_needed(@access_info, force_refresh)
|
54
61
|
end
|
55
62
|
|
56
|
-
def refresh_if_needed(access_info)
|
57
|
-
if access_info.expires_soon?
|
63
|
+
def refresh_if_needed(access_info, force_refresh = false)
|
64
|
+
if access_info.expires_soon? || force_refresh
|
58
65
|
uaa_client.refresh(access_info)
|
59
66
|
else
|
60
67
|
access_info
|
data/lib/cli/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bosh_cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3232.
|
4
|
+
version: 1.3232.24.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- VMware
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-11-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bosh_common
|
@@ -16,28 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1.3232.
|
19
|
+
version: 1.3232.24.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 1.3232.
|
26
|
+
version: 1.3232.24.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bosh-template
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 1.3232.
|
33
|
+
version: 1.3232.24.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 1.3232.
|
40
|
+
version: 1.3232.24.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: cf-uaa-lib
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -128,14 +128,14 @@ dependencies:
|
|
128
128
|
requirements:
|
129
129
|
- - "~>"
|
130
130
|
- !ruby/object:Gem::Version
|
131
|
-
version: 1.3232.
|
131
|
+
version: 1.3232.24.0
|
132
132
|
type: :runtime
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
136
|
- - "~>"
|
137
137
|
- !ruby/object:Gem::Version
|
138
|
-
version: 1.3232.
|
138
|
+
version: 1.3232.24.0
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
140
|
name: net-ssh
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|