pubcontrol 1.2.3 → 1.3.0

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: 891f89bab7da9ee7d4239ddab6c29271ab358f4ead3af66131727b663c23bd0c
4
- data.tar.gz: 4e5d9c817a5e6c27b5390aae757a0870f4d834fdfd4c92a3b12f96d24441dd3c
3
+ metadata.gz: f090ee8b6fea8ce3141240d269550dddd1e1ad44ac852523548ac4350eea37e1
4
+ data.tar.gz: 7846f51731e82a8bf5553777202f0ec4e6a67457b04c07bc684ed46e2b7d0403
5
5
  SHA512:
6
- metadata.gz: 5162d526a1b3d440f51bdff86d96727a73a99ee325c23b9b08e7693e57804af3fdfdf5d1aaf01aadb2f441aebb6e80356af4ca5cf616e917b7eb4d8092db3fbf
7
- data.tar.gz: 313dbed3224a9de05c0fa1108303666f174e1924c04b4f2ae3e415ca8e1750c7fbec9d41baa858613876e218b8deb5755843d743c33f6a1d400e8dc35ef3adc6
6
+ metadata.gz: 9ec5f93e56eedf2f7b18af0e5fbd3fd6d4d770470c83b90c1637a0b48ddbf9c823e26c8b708a4c9d953acadea5b0dd2be6322656a5518f9a817386e44880ff46
7
+ data.tar.gz: db16ff82c0e643042b5262449f20d43ce3ed731677853344d83e46b041267a13195d39878bf6ea09a135d15fab5b4b325efd86e220391b102cec46d166eea0e9
data/lib/pubcontrol.rb CHANGED
@@ -63,6 +63,8 @@ class PubControl
63
63
  pub = PubControlClient.new(entry['uri'])
64
64
  if entry.key?('iss')
65
65
  pub.set_auth_jwt({'iss' => entry['iss']}, entry['key'])
66
+ elsif entry.key?('key')
67
+ pub.set_auth_bearer(entry['key'])
66
68
  end
67
69
  @clients.push(pub)
68
70
  end
@@ -34,6 +34,7 @@ class PubControlClient
34
34
  @auth_basic_pass = nil
35
35
  @auth_jwt_claim = nil
36
36
  @auth_jwt_key = nil
37
+ @auth_bearer_key = nil
37
38
  @http = Net::HTTP::Persistent.new @object_id.to_s
38
39
  @http.open_timeout = 10
39
40
  @http.read_timeout = 10
@@ -57,6 +58,14 @@ class PubControlClient
57
58
  end
58
59
  end
59
60
 
61
+ # Call this method and pass a key to use bearer authenticate
62
+ # with the configured endpoint
63
+ def set_auth_bearer(key)
64
+ @lock.synchronize do
65
+ @auth_bearer_key = key
66
+ end
67
+ end
68
+
60
69
  # The synchronous publish method for publishing the specified item to the
61
70
  # specified channels on the configured endpoint.
62
71
  def publish(channels, item)
@@ -131,7 +140,10 @@ class PubControlClient
131
140
  # data to the endpoint. This method accepts the URI endpoint, authorization
132
141
  # header, and a list of items to publish.
133
142
  def pubcall(uri, auth_header, items)
134
- uri = URI(uri + '/publish/')
143
+ if uri.to_s[-1] != '/'
144
+ uri = uri.to_s + '/'
145
+ end
146
+ uri = URI(uri + 'publish/')
135
147
  content = Hash.new
136
148
  content['items'] = items
137
149
  request = Net::HTTP::Post.new(uri.request_uri)
@@ -235,6 +247,8 @@ class PubControlClient
235
247
  claim = @auth_jwt_claim
236
248
  end
237
249
  return 'Bearer ' + JWT.encode(claim, @auth_jwt_key)
250
+ elsif !@auth_bearer_key.nil?
251
+ return 'Bearer ' + @auth_bearer_key
238
252
  else
239
253
  return nil
240
254
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pubcontrol
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.3
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Konstantin Bokarius
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-01-27 00:00:00.000000000 Z
11
+ date: 2023-09-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: algorithms
@@ -82,8 +82,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
82
82
  - !ruby/object:Gem::Version
83
83
  version: '0'
84
84
  requirements: []
85
- rubyforge_project:
86
- rubygems_version: 2.7.6
85
+ rubygems_version: 3.0.3.1
87
86
  signing_key:
88
87
  specification_version: 4
89
88
  summary: Ruby EPCP library