concourse.rb 0.1.0.pre.2 → 0.1.0.pre.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +40 -1
- data/concourse.rb.gemspec +5 -0
- data/lib/concourse.rb +2 -0
- data/lib/concourse/client.rb +26 -1
- data/lib/concourse/headers.rb +41 -0
- data/lib/concourse/sub_clients.rb +6 -0
- data/lib/concourse/sub_clients/skymarshal_client.rb +100 -0
- data/lib/concourse/urls.rb +19 -0
- data/lib/concourse/version.rb +1 -1
- metadata +76 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a9d3b78394c237f40be7120c376a08f2589674df770193621459b707dcb5a82b
|
4
|
+
data.tar.gz: fc30e4e5ac9607112f39e1a6e08373d26757c43a5383de9de6034acf9e466724
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 29db3b96e36cf7fd5031087804b0344548f062b62e74d44d71ad6cdb390a1010ea120d26b5f67b4d23b77f3423376399595785a90a6b9c029e3ef086de75ed58
|
7
|
+
data.tar.gz: a91efec92fe4b9261576c37581098345c376ed21387f85123577ab9b27ec025a60126c1cc891e06c86db5d1365abcea6c5c09c60b9122145abdb6fa0d98ce6d4
|
data/Gemfile.lock
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
concourse.rb (0.1.0.pre.
|
4
|
+
concourse.rb (0.1.0.pre.3)
|
5
|
+
dry-schema (~> 0.5)
|
5
6
|
excon (~> 0.72)
|
7
|
+
semantic (~> 1.5)
|
6
8
|
|
7
9
|
GEM
|
8
10
|
remote: https://rubygems.org/
|
@@ -18,7 +20,38 @@ GEM
|
|
18
20
|
colored2 (3.1.2)
|
19
21
|
concurrent-ruby (1.1.7)
|
20
22
|
diff-lcs (1.4.4)
|
23
|
+
dry-configurable (0.12.0)
|
24
|
+
concurrent-ruby (~> 1.0)
|
25
|
+
dry-core (~> 0.5, >= 0.5.0)
|
26
|
+
dry-container (0.7.2)
|
27
|
+
concurrent-ruby (~> 1.0)
|
28
|
+
dry-configurable (~> 0.1, >= 0.1.3)
|
29
|
+
dry-core (0.5.0)
|
30
|
+
concurrent-ruby (~> 1.0)
|
31
|
+
dry-equalizer (0.3.0)
|
32
|
+
dry-inflector (0.2.0)
|
33
|
+
dry-initializer (3.0.4)
|
34
|
+
dry-logic (1.1.0)
|
35
|
+
concurrent-ruby (~> 1.0)
|
36
|
+
dry-core (~> 0.5, >= 0.5)
|
37
|
+
dry-schema (0.6.0)
|
38
|
+
concurrent-ruby (~> 1.0)
|
39
|
+
dry-configurable (~> 0.8, >= 0.8.0)
|
40
|
+
dry-core (~> 0.4)
|
41
|
+
dry-equalizer (~> 0.2)
|
42
|
+
dry-initializer (~> 3.0)
|
43
|
+
dry-logic (~> 1.0)
|
44
|
+
dry-types (~> 1.0)
|
45
|
+
dry-types (1.4.0)
|
46
|
+
concurrent-ruby (~> 1.0)
|
47
|
+
dry-container (~> 0.3)
|
48
|
+
dry-core (~> 0.4, >= 0.4.4)
|
49
|
+
dry-equalizer (~> 0.3)
|
50
|
+
dry-inflector (~> 0.1, >= 0.1.2)
|
51
|
+
dry-logic (~> 1.0, >= 1.0.2)
|
21
52
|
excon (0.78.1)
|
53
|
+
faker (2.15.1)
|
54
|
+
i18n (>= 1.6, < 2)
|
22
55
|
faraday (1.3.0)
|
23
56
|
faraday-net_http (~> 1.0)
|
24
57
|
multipart-post (>= 1.2, < 3)
|
@@ -29,6 +62,7 @@ GEM
|
|
29
62
|
concurrent-ruby (~> 1.0)
|
30
63
|
i18n (1.8.6)
|
31
64
|
concurrent-ruby (~> 1.0)
|
65
|
+
jwt (2.2.2)
|
32
66
|
lino (1.7.0)
|
33
67
|
hamster (~> 3.0)
|
34
68
|
open4 (~> 1.3)
|
@@ -38,6 +72,7 @@ GEM
|
|
38
72
|
faraday (>= 0.9)
|
39
73
|
sawyer (~> 0.8.0, >= 0.5.3)
|
40
74
|
open4 (1.3.4)
|
75
|
+
openssl (2.2.0)
|
41
76
|
public_suffix (4.0.6)
|
42
77
|
rake (13.0.3)
|
43
78
|
rake_circle_ci (0.9.0)
|
@@ -79,6 +114,7 @@ GEM
|
|
79
114
|
sawyer (0.8.2)
|
80
115
|
addressable (>= 2.3.5)
|
81
116
|
faraday (> 0.8, < 2.0)
|
117
|
+
semantic (1.6.1)
|
82
118
|
sshkey (2.0.0)
|
83
119
|
tzinfo (2.0.4)
|
84
120
|
concurrent-ruby (~> 1.0)
|
@@ -92,7 +128,10 @@ PLATFORMS
|
|
92
128
|
DEPENDENCIES
|
93
129
|
bundler (~> 2.0)
|
94
130
|
concourse.rb!
|
131
|
+
faker (~> 2.15)
|
95
132
|
gem-release (~> 2.0)
|
133
|
+
jwt (~> 2.2)
|
134
|
+
openssl (~> 2.2)
|
96
135
|
rake (~> 13.0)
|
97
136
|
rake_circle_ci (~> 0.9)
|
98
137
|
rake_github (~> 0.5)
|
data/concourse.rb.gemspec
CHANGED
@@ -26,6 +26,8 @@ Gem::Specification.new do |spec|
|
|
26
26
|
spec.required_ruby_version = '>= 2.6.0'
|
27
27
|
|
28
28
|
spec.add_dependency 'excon', '~> 0.72'
|
29
|
+
spec.add_dependency 'dry-schema', '~> 0.5'
|
30
|
+
spec.add_dependency 'semantic', '~> 1.5'
|
29
31
|
|
30
32
|
spec.add_development_dependency 'bundler', '~> 2.0'
|
31
33
|
spec.add_development_dependency 'rake', '~> 13.0'
|
@@ -34,5 +36,8 @@ Gem::Specification.new do |spec|
|
|
34
36
|
spec.add_development_dependency 'rake_ssh', '~> 0.4'
|
35
37
|
spec.add_development_dependency 'rake_gpg', '~> 0.12'
|
36
38
|
spec.add_development_dependency 'rspec', '~> 3.9'
|
39
|
+
spec.add_development_dependency 'jwt', '~> 2.2'
|
40
|
+
spec.add_development_dependency 'openssl', '~> 2.2'
|
41
|
+
spec.add_development_dependency 'faker', '~> 2.15'
|
37
42
|
spec.add_development_dependency 'gem-release', '~> 2.0'
|
38
43
|
end
|
data/lib/concourse.rb
CHANGED
data/lib/concourse/client.rb
CHANGED
@@ -1,7 +1,32 @@
|
|
1
|
+
require 'excon'
|
2
|
+
require 'concourse/sub_clients'
|
3
|
+
|
1
4
|
module Concourse
|
2
5
|
class Client
|
3
|
-
def initialize
|
6
|
+
def initialize(options)
|
7
|
+
@options = options
|
8
|
+
end
|
9
|
+
|
10
|
+
def for_skymarshal
|
11
|
+
Concourse::SubClients::SkymarshalClient.new(
|
12
|
+
@options.merge(version: get_info[:version]))
|
13
|
+
end
|
14
|
+
|
15
|
+
def get_info
|
16
|
+
JSON.parse(
|
17
|
+
Excon.get(Concourse::Urls.info_url(@options[:url]))
|
18
|
+
.body,
|
19
|
+
symbolize_names: true)
|
20
|
+
end
|
21
|
+
|
22
|
+
def ==(other)
|
23
|
+
other.class == self.class && other.state == state
|
24
|
+
end
|
25
|
+
|
26
|
+
protected
|
4
27
|
|
28
|
+
def state
|
29
|
+
[@options]
|
5
30
|
end
|
6
31
|
end
|
7
32
|
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'base64'
|
2
|
+
|
3
|
+
module Concourse
|
4
|
+
module ContentTypes
|
5
|
+
APPLICATION_WWW_FORM_URLENCODED = 'application/x-www-form-urlencoded'
|
6
|
+
end
|
7
|
+
|
8
|
+
module Authorization
|
9
|
+
def self.bearer(token)
|
10
|
+
"Bearer #{token}"
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.basic(username, password)
|
14
|
+
"Basic #{Base64.encode64("#{username}:#{password}")}"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
module HeaderNames
|
19
|
+
def self.content_type
|
20
|
+
"Content-Type"
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.authorization
|
24
|
+
"Authorization"
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.date
|
28
|
+
"Date"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
module Headers
|
33
|
+
def self.content_type(content_type)
|
34
|
+
{Concourse::HeaderNames.content_type => content_type}
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.authorization(authorization)
|
38
|
+
{Concourse::HeaderNames.authorization => authorization}
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,100 @@
|
|
1
|
+
require 'semantic'
|
2
|
+
require 'date'
|
3
|
+
|
4
|
+
require 'concourse/urls'
|
5
|
+
require 'concourse/headers'
|
6
|
+
|
7
|
+
module Concourse
|
8
|
+
module SubClients
|
9
|
+
class SkymarshalClient
|
10
|
+
VERSION_6_1 = Semantic::Version.new('6.1.0')
|
11
|
+
|
12
|
+
def initialize(options)
|
13
|
+
@url = options[:url]
|
14
|
+
@version = Semantic::Version.new(options[:version])
|
15
|
+
end
|
16
|
+
|
17
|
+
def create_token(parameters)
|
18
|
+
url = create_token_url
|
19
|
+
headers = create_token_headers
|
20
|
+
body = create_token_body(parameters)
|
21
|
+
|
22
|
+
token_response = Excon.post(url, headers: headers, body: body)
|
23
|
+
|
24
|
+
token(token_response)
|
25
|
+
end
|
26
|
+
|
27
|
+
def ==(other)
|
28
|
+
other.class == self.class && other.state == state
|
29
|
+
end
|
30
|
+
|
31
|
+
protected
|
32
|
+
|
33
|
+
def state
|
34
|
+
[@options]
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def create_token_url
|
40
|
+
@version >= VERSION_6_1 ?
|
41
|
+
Concourse::Urls.sky_issuer_token_url(@url) :
|
42
|
+
Concourse::Urls.sky_token_url(@url)
|
43
|
+
end
|
44
|
+
|
45
|
+
def create_token_headers
|
46
|
+
{}
|
47
|
+
.merge(Concourse::Headers.content_type(
|
48
|
+
Concourse::ContentTypes::APPLICATION_WWW_FORM_URLENCODED))
|
49
|
+
.merge(Concourse::Headers.authorization(
|
50
|
+
Concourse::Authorization.basic(
|
51
|
+
"fly", "Zmx5")))
|
52
|
+
end
|
53
|
+
|
54
|
+
def create_token_body(parameters)
|
55
|
+
username = parameters[:username]
|
56
|
+
password = parameters[:password]
|
57
|
+
|
58
|
+
scope = @version >= VERSION_6_1 ?
|
59
|
+
'openid profile email federated:id groups' :
|
60
|
+
'openid+profile+email+federated:id+groups'
|
61
|
+
|
62
|
+
URI.encode_www_form({
|
63
|
+
grant_type: 'password',
|
64
|
+
username: username,
|
65
|
+
password: password,
|
66
|
+
scope: scope
|
67
|
+
})
|
68
|
+
end
|
69
|
+
|
70
|
+
def token(token_response)
|
71
|
+
token_response_date = @version >= VERSION_6_1 ?
|
72
|
+
DateTime.parse(
|
73
|
+
token_response.headers[Concourse::HeaderNames.date]) :
|
74
|
+
nil
|
75
|
+
token_response_body =
|
76
|
+
JSON.parse(token_response.body, symbolize_names: true)
|
77
|
+
|
78
|
+
seconds_in_a_day = 60 * 60 * 24
|
79
|
+
|
80
|
+
@version >= VERSION_6_1 ?
|
81
|
+
{
|
82
|
+
access_token: token_response_body[:access_token],
|
83
|
+
token_type: token_response_body[:token_type].downcase,
|
84
|
+
expires_at:
|
85
|
+
(token_response_date +
|
86
|
+
(token_response_body[:expires_in] /
|
87
|
+
seconds_in_a_day))
|
88
|
+
.iso8601,
|
89
|
+
id_token: token_response_body[:id_token]
|
90
|
+
} :
|
91
|
+
{
|
92
|
+
access_token: token_response_body[:access_token],
|
93
|
+
token_type: token_response_body[:token_type].downcase,
|
94
|
+
expires_at: token_response_body[:expiry],
|
95
|
+
id_token: token_response_body[:access_token]
|
96
|
+
}
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Concourse
|
2
|
+
module Urls
|
3
|
+
def self.api_url(concourse_url)
|
4
|
+
"#{concourse_url}/api/v1"
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.sky_token_url(concourse_url)
|
8
|
+
"#{concourse_url}/sky/token"
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.sky_issuer_token_url(concourse_url)
|
12
|
+
"#{concourse_url}/sky/issuer/token"
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.info_url(concourse_url)
|
16
|
+
"#{api_url(concourse_url)}/info"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/concourse/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: concourse.rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.0.pre.
|
4
|
+
version: 0.1.0.pre.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Toby Clemson
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-01-
|
11
|
+
date: 2021-01-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: excon
|
@@ -24,6 +24,34 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0.72'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: dry-schema
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.5'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.5'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: semantic
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.5'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.5'
|
27
55
|
- !ruby/object:Gem::Dependency
|
28
56
|
name: bundler
|
29
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -122,6 +150,48 @@ dependencies:
|
|
122
150
|
- - "~>"
|
123
151
|
- !ruby/object:Gem::Version
|
124
152
|
version: '3.9'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: jwt
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - "~>"
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '2.2'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - "~>"
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '2.2'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: openssl
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - "~>"
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '2.2'
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - "~>"
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '2.2'
|
181
|
+
- !ruby/object:Gem::Dependency
|
182
|
+
name: faker
|
183
|
+
requirement: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - "~>"
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: '2.15'
|
188
|
+
type: :development
|
189
|
+
prerelease: false
|
190
|
+
version_requirements: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - "~>"
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: '2.15'
|
125
195
|
- !ruby/object:Gem::Dependency
|
126
196
|
name: gem-release
|
127
197
|
requirement: !ruby/object:Gem::Requirement
|
@@ -154,6 +224,10 @@ files:
|
|
154
224
|
- concourse.rb.gemspec
|
155
225
|
- lib/concourse.rb
|
156
226
|
- lib/concourse/client.rb
|
227
|
+
- lib/concourse/headers.rb
|
228
|
+
- lib/concourse/sub_clients.rb
|
229
|
+
- lib/concourse/sub_clients/skymarshal_client.rb
|
230
|
+
- lib/concourse/urls.rb
|
157
231
|
- lib/concourse/version.rb
|
158
232
|
homepage: https://github.com/infrablocks/concourse.rb
|
159
233
|
licenses:
|