ruby-jss 4.0.0b1 → 4.1.0b2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +1 -1
- data/lib/jamf/api/connection/classic_api.rb +14 -20
- data/lib/jamf/api/connection/connect.rb +1 -10
- data/lib/jamf/api/connection/jamf_pro_api.rb +10 -7
- data/lib/jamf/api/connection/token.rb +4 -4
- data/lib/jamf/api/connection.rb +2 -2
- data/lib/jamf/version.rb +1 -1
- metadata +16 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 04a9f6decd6b58c0603dcad2e8a553c3ac80e0147618c8fd7fb08d545ff1d537
|
4
|
+
data.tar.gz: '050849dd7596137de61bc096b6922bfa7a8e1d98dbd7b41048d8eb7552be13e9'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f5762d83c0693aacdc610026c3f81f5675ec599caf80b7064163b32ca218bb19739bec04360e6f8b02851a51bf66ed26dca2de50fbf317a6dc8d30dc2d88c612
|
7
|
+
data.tar.gz: e866b77f659b4a2d28c624e47ff40676894a1515c277f4e350d0470b73881f46cab5ea2686006b27f7d36f0ebdab886ab5cd391ce14050f6004cf5c84bc6254f
|
data/CHANGES.md
CHANGED
@@ -15,7 +15,7 @@ __Please update all installations of ruby-jss to at least v1.6.0.__
|
|
15
15
|
Many many thanks to actae0n of Blacksun Hackers Club for reporting this issue and providing examples of how it could be exploited.
|
16
16
|
|
17
17
|
--------
|
18
|
-
## \[4.0.0] 2024-
|
18
|
+
## \[4.0.0] 2024-02-05
|
19
19
|
|
20
20
|
### Changed
|
21
21
|
- Jamf::ComputerPrestage now accesses the v3 endpoints as needed - the v1 and some v2 endpoints are deprecated and will be removed from the Jamf Pro API sometime soon
|
@@ -61,7 +61,7 @@ module Jamf
|
|
61
61
|
def c_get(rsrc, format = :json, raw_json: false)
|
62
62
|
rsrc = rsrc.delete_prefix Jamf::Connection::SLASH
|
63
63
|
|
64
|
-
validate_connected
|
64
|
+
validate_connected
|
65
65
|
raise Jamf::InvalidDataError, 'format must be :json or :xml' unless Jamf::Connection::GET_FORMATS.include?(format)
|
66
66
|
|
67
67
|
resp =
|
@@ -92,7 +92,7 @@ module Jamf
|
|
92
92
|
# @return [String] the xml response from the server.
|
93
93
|
#
|
94
94
|
def c_post(rsrc, xml)
|
95
|
-
validate_connected
|
95
|
+
validate_connected
|
96
96
|
|
97
97
|
rsrc = rsrc.delete_prefix Jamf::Connection::SLASH
|
98
98
|
|
@@ -127,7 +127,7 @@ module Jamf
|
|
127
127
|
# @return [String] the xml response from the server.
|
128
128
|
#
|
129
129
|
def c_put(rsrc, xml)
|
130
|
-
validate_connected
|
130
|
+
validate_connected
|
131
131
|
|
132
132
|
rsrc = rsrc.delete_prefix Jamf::Connection::SLASH
|
133
133
|
|
@@ -160,7 +160,7 @@ module Jamf
|
|
160
160
|
# @return [String] the xml response from the server.
|
161
161
|
#
|
162
162
|
def c_delete(rsrc)
|
163
|
-
validate_connected
|
163
|
+
validate_connected
|
164
164
|
raise MissingDataError, 'Missing :rsrc' if rsrc.nil?
|
165
165
|
|
166
166
|
rsrc = rsrc.delete_prefix Jamf::Connection::SLASH
|
@@ -195,23 +195,14 @@ module Jamf
|
|
195
195
|
# @return [String] the xml response from the server.
|
196
196
|
#
|
197
197
|
def upload(rsrc, local_file)
|
198
|
-
validate_connected
|
198
|
+
validate_connected
|
199
199
|
rsrc = rsrc.delete_prefix Jamf::Connection::SLASH
|
200
200
|
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
'application/octet-stream',
|
206
|
-
local_file.basename.to_s
|
207
|
-
)
|
201
|
+
payload = {}
|
202
|
+
payload[:name] = Faraday::Multipart::FilePart.new(local_file.to_s, 'application/octet-stream')
|
203
|
+
|
204
|
+
resp = @c_cnx.post rsrc, payload
|
208
205
|
|
209
|
-
# send it and get the response
|
210
|
-
resp =
|
211
|
-
@c_cnx.post rsrc do |req|
|
212
|
-
req.headers['Content-Type'] = 'multipart/form-data'
|
213
|
-
req.body = { name: upfile }
|
214
|
-
end
|
215
206
|
@last_http_response = resp
|
216
207
|
|
217
208
|
unless resp.success?
|
@@ -228,7 +219,10 @@ module Jamf
|
|
228
219
|
# create the faraday CAPI connection object
|
229
220
|
def create_classic_connection
|
230
221
|
Faraday.new(@c_base_url, ssl: ssl_options) do |cnx|
|
231
|
-
|
222
|
+
# use a proc for the token value, so its looked up on every request
|
223
|
+
# meaning we don't have to validate that the token is still valid before every request
|
224
|
+
# because the Token instance will (usually) refresh it automatically.
|
225
|
+
cnx.request :authorization, 'Bearer', -> { @token.token }
|
232
226
|
|
233
227
|
cnx.options[:timeout] = @timeout
|
234
228
|
cnx.options[:open_timeout] = @open_timeout
|
@@ -236,7 +230,7 @@ module Jamf
|
|
236
230
|
cnx.request :multipart
|
237
231
|
cnx.request :url_encoded
|
238
232
|
|
239
|
-
cnx.adapter
|
233
|
+
cnx.adapter :net_http
|
240
234
|
end
|
241
235
|
end
|
242
236
|
|
@@ -264,18 +264,9 @@ module Jamf
|
|
264
264
|
|
265
265
|
# raise exception if not connected, and make sure we're using
|
266
266
|
# the current token
|
267
|
-
def validate_connected
|
267
|
+
def validate_connected
|
268
268
|
using_dft = 'Jamf.cnx' if self == Jamf.cnx
|
269
269
|
raise Jamf::InvalidConnectionError, "Connection '#{@name}' Not Connected. Use #{using_dft}.connect first." unless connected?
|
270
|
-
|
271
|
-
update_refreshed_token(subcnx)
|
272
|
-
end
|
273
|
-
|
274
|
-
# always use the current token, which by default will auto-refresh
|
275
|
-
def update_refreshed_token(subcnx)
|
276
|
-
return if subcnx.headers['Authorization'] == "Bearer #{@token.token}"
|
277
|
-
|
278
|
-
subcnx.authorization :Bearer, @token.token
|
279
270
|
end
|
280
271
|
|
281
272
|
# With a REST connection, there isn't any real "connection" to disconnect from
|
@@ -37,7 +37,10 @@ module Jamf
|
|
37
37
|
#######################################################
|
38
38
|
def create_jp_connection(parse_json: true)
|
39
39
|
Faraday.new(@jp_base_url, ssl: ssl_options) do |cnx|
|
40
|
-
|
40
|
+
# use a proc for the token value, so its looked up on every request
|
41
|
+
# meaning we don't have to validate that the token is still valid before every request
|
42
|
+
# because the Token instance will (usually) refresh it automatically.
|
43
|
+
cnx.request :authorization, 'Bearer', -> { @token.token }
|
41
44
|
|
42
45
|
cnx.options[:timeout] = @timeout
|
43
46
|
cnx.options[:open_timeout] = @open_timeout
|
@@ -47,7 +50,7 @@ module Jamf
|
|
47
50
|
cnx.response :json, parser_options: { symbolize_names: true }
|
48
51
|
end
|
49
52
|
|
50
|
-
cnx.adapter
|
53
|
+
cnx.adapter :net_http
|
51
54
|
end
|
52
55
|
end
|
53
56
|
|
@@ -57,7 +60,7 @@ module Jamf
|
|
57
60
|
# @return [Hash] the result of the get
|
58
61
|
#######################################################
|
59
62
|
def jp_get(rsrc)
|
60
|
-
validate_connected
|
63
|
+
validate_connected
|
61
64
|
rsrc = rsrc.delete_prefix Jamf::Connection::SLASH
|
62
65
|
resp = @jp_cnx.get(rsrc) do |req|
|
63
66
|
# Modify the request here if needed.
|
@@ -82,7 +85,7 @@ module Jamf
|
|
82
85
|
# @return [String] the response body
|
83
86
|
#######################################################
|
84
87
|
def jp_post(rsrc, data)
|
85
|
-
validate_connected
|
88
|
+
validate_connected
|
86
89
|
rsrc = rsrc.delete_prefix Jamf::Connection::SLASH
|
87
90
|
resp = @jp_cnx.post(rsrc) do |req|
|
88
91
|
req.body = data
|
@@ -105,7 +108,7 @@ module Jamf
|
|
105
108
|
#
|
106
109
|
#######################################################
|
107
110
|
def jp_put(rsrc, data)
|
108
|
-
validate_connected
|
111
|
+
validate_connected
|
109
112
|
rsrc = rsrc.delete_prefix Jamf::Connection::SLASH
|
110
113
|
resp = @jp_cnx.put(rsrc) do |req|
|
111
114
|
req.body = data
|
@@ -128,7 +131,7 @@ module Jamf
|
|
128
131
|
#
|
129
132
|
#######################################################
|
130
133
|
def jp_patch(rsrc, data)
|
131
|
-
validate_connected
|
134
|
+
validate_connected
|
132
135
|
rsrc = rsrc.delete_prefix Jamf::Connection::SLASH
|
133
136
|
resp = @jp_cnx.patch(rsrc) do |req|
|
134
137
|
req.body = data
|
@@ -149,7 +152,7 @@ module Jamf
|
|
149
152
|
#
|
150
153
|
#######################################################
|
151
154
|
def jp_delete(rsrc)
|
152
|
-
validate_connected
|
155
|
+
validate_connected
|
153
156
|
rsrc = rsrc.delete_prefix Jamf::Connection::SLASH
|
154
157
|
resp = @jp_cnx.delete rsrc
|
155
158
|
@last_http_response = resp
|
@@ -534,11 +534,11 @@ module Jamf
|
|
534
534
|
con.options[:timeout] = @timeout
|
535
535
|
con.options[:open_timeout] = @timeout
|
536
536
|
if token
|
537
|
-
con.authorization
|
537
|
+
con.request :authorization, 'Bearer', token
|
538
538
|
else
|
539
|
-
con.
|
539
|
+
con.request :authorization, :basic, @user, Base64.decode64(@pw)
|
540
540
|
end
|
541
|
-
con.adapter
|
541
|
+
con.adapter :net_http
|
542
542
|
end # Faraday.new
|
543
543
|
end # token_connection
|
544
544
|
|
@@ -551,7 +551,7 @@ module Jamf
|
|
551
551
|
fcnx.request :url_encoded
|
552
552
|
# activates the json response middleware, parsing all valid response bodies with JSON.parse
|
553
553
|
fcnx.response :json, parser_options: { symbolize_names: true }
|
554
|
-
fcnx.adapter
|
554
|
+
fcnx.adapter :net_http
|
555
555
|
end
|
556
556
|
end # token_connection
|
557
557
|
|
data/lib/jamf/api/connection.rb
CHANGED
data/lib/jamf/version.rb
CHANGED
metadata
CHANGED
@@ -1,16 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-jss
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.1.0b2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Lasell
|
8
8
|
- Aurica Hayes
|
9
|
-
|
10
|
-
autorequire:
|
9
|
+
autorequire:
|
11
10
|
bindir: bin
|
12
11
|
cert_chain: []
|
13
|
-
date: 2024-
|
12
|
+
date: 2024-04-02 00:00:00.000000000 Z
|
14
13
|
dependencies:
|
15
14
|
- !ruby/object:Gem::Dependency
|
16
15
|
name: CFPropertyList
|
@@ -52,21 +51,24 @@ dependencies:
|
|
52
51
|
requirements:
|
53
52
|
- - "~>"
|
54
53
|
- !ruby/object:Gem::Version
|
55
|
-
version: '
|
54
|
+
version: '2.0'
|
56
55
|
type: :runtime
|
57
56
|
prerelease: false
|
58
57
|
version_requirements: !ruby/object:Gem::Requirement
|
59
58
|
requirements:
|
60
59
|
- - "~>"
|
61
60
|
- !ruby/object:Gem::Version
|
62
|
-
version: '
|
61
|
+
version: '2.0'
|
63
62
|
- !ruby/object:Gem::Dependency
|
64
|
-
name:
|
63
|
+
name: faraday-multipart
|
65
64
|
requirement: !ruby/object:Gem::Requirement
|
66
65
|
requirements:
|
67
66
|
- - "~>"
|
68
67
|
- !ruby/object:Gem::Version
|
69
68
|
version: '1.0'
|
69
|
+
- - ">="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: 1.0.4
|
70
72
|
type: :runtime
|
71
73
|
prerelease: false
|
72
74
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -74,6 +76,9 @@ dependencies:
|
|
74
76
|
- - "~>"
|
75
77
|
- !ruby/object:Gem::Version
|
76
78
|
version: '1.0'
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: 1.0.4
|
77
82
|
- !ruby/object:Gem::Dependency
|
78
83
|
name: concurrent-ruby
|
79
84
|
requirement: !ruby/object:Gem::Requirement
|
@@ -921,10 +926,10 @@ homepage: http://pixaranimationstudios.github.io/ruby-jss/
|
|
921
926
|
licenses:
|
922
927
|
- Nonstandard
|
923
928
|
metadata: {}
|
924
|
-
post_install_message:
|
929
|
+
post_install_message:
|
925
930
|
rdoc_options:
|
926
931
|
- "--title"
|
927
|
-
-
|
932
|
+
- Jamf
|
928
933
|
- "--line-numbers"
|
929
934
|
- "--main"
|
930
935
|
- README.md
|
@@ -941,8 +946,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
941
946
|
- !ruby/object:Gem::Version
|
942
947
|
version: 1.3.1
|
943
948
|
requirements: []
|
944
|
-
rubygems_version: 3.
|
945
|
-
signing_key:
|
949
|
+
rubygems_version: 3.1.4
|
950
|
+
signing_key:
|
946
951
|
specification_version: 4
|
947
952
|
summary: A Ruby interface to the Jamf Pro REST APIs
|
948
953
|
test_files: []
|