faye-authentication 1.10.0 → 1.11.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: 72258f703034d2918db6f64c09d3a6425723d7b8da3ad1b4d96ae919f115eaf3
4
- data.tar.gz: cf7e35e01b7d9c9a1ab23cc5c8ad9ad6d0d389e52f1d8ca111d9aef043d4f217
3
+ metadata.gz: 23d0511cded90a176f335c918ddd7ac42559d80306818da3505dbc24341b24f8
4
+ data.tar.gz: 3aaaa3a5e286ee2952b0098b86c6d8d10aeb84c448f606044d406baeec6d074f
5
5
  SHA512:
6
- metadata.gz: 4c9885e00a0ea3ed9b7f2c032c17295fe085d35b7cc6ee3db64476b1752d5b071ca94637ddecb25b7fe101506b5808b15da74dbca8c04599be22248fdf9e3d59
7
- data.tar.gz: 6171172fcf7f70fb42ee65e657cdb4a02a47104ed069a642bf1ad166494a6452204a289b6d16ec203217be12aa4adfa3f0fd9737259457a7b1a235c4c64df4d6
6
+ metadata.gz: 1e5e77a5ee7df63d0a0c62e813431baa690d16b5532a2f10494e72ca998b4393fa50f5f21adfff356c608892974a1c8b7e0fa0133d502577ef8919922df65511
7
+ data.tar.gz: d2bcf4df68befe130af88a1e3a94a566374257385e8b737f16c76f22a70f8a042b15d2a205302bbad658e271ad97ce16a3021b25453263ae5f672612038a0375
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
+ ## 1.11.0
2
+ - Optional authentication for `Faye::Authentication::HTTPClient` (#12)
3
+
4
+ ## 1.10.0
5
+ - Remove signature from the server response (#11)
6
+
1
7
  ## 1.8.1
2
8
  - Fix bad parameter passed to Net::HTTP::Post in HTTP Client (thanks @evserykh)
9
+
3
10
  ## 1.8.0
4
11
  - Wait a delay before trying to fetch a signature after an error
5
12
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.10.0
1
+ 1.11.0
@@ -4,16 +4,16 @@ module Faye
4
4
  module Authentication
5
5
  class HTTPClient
6
6
 
7
- def self.publish(url, channel, data, key)
7
+ def self.publish(url, channel, data, key, options = {})
8
8
  uri = URI(url)
9
- req = prepare_request(uri.request_uri, channel, data, key)
9
+ req = prepare_request(uri.request_uri, channel, data, key, options)
10
10
  Net::HTTP.start(uri.hostname, uri.port, :use_ssl => uri.scheme == 'https') { |http| http.request(req) }
11
11
  end
12
12
 
13
- def self.prepare_request(uri, channel, data, key)
13
+ def self.prepare_request(uri, channel, data, key, options = {})
14
14
  req = Net::HTTP::Post.new(uri)
15
15
  message = {'channel' => channel, 'clientId' => 'http'}
16
- message['signature'] = Faye::Authentication.sign(message, key)
16
+ message['signature'] = Faye::Authentication.sign(message, key) if Faye::Authentication.authentication_required?(message, options)
17
17
  message['data'] = data
18
18
  req.set_form_data(message: JSON.dump(message))
19
19
  req
@@ -9,11 +9,22 @@ describe Faye::Authentication::HTTPClient do
9
9
  message = {'channel' => '/foo/bar', 'clientId' => 'http'}
10
10
  message['signature'] = Faye::Authentication.sign(message, 'my private key')
11
11
  message['data'] = 'hello'
12
- request = stub_request(:post, "http://www.example.com").with(:body => {:message => JSON.dump(message)}).to_return(:status => 200, :body => "", :headers => {})
12
+ request = stub_request(:post, "http://www.example.com").with(body: {message: JSON.dump(message)}).to_return(status: 200, body: "", headers: {})
13
13
  Faye::Authentication::HTTPClient.publish('http://www.example.com', '/foo/bar', "hello", 'my private key')
14
14
  expect(request).to have_been_made
15
15
  end
16
16
 
17
+ it 'should not add a signature if the channel is whitelisted' do
18
+ message = {'channel' => '/foo/bar', 'clientId' => 'http'}
19
+ message['data'] = 'hello'
20
+ request = stub_request(:post, "http://www.example.com").with(body: {message: JSON.dump(message)}).to_return(status: 200, body: "", headers: {})
21
+ whitelist = lambda do |channel|
22
+ channel.start_with?('/foo/')
23
+ end
24
+ Faye::Authentication::HTTPClient.publish('http://www.example.com', '/foo/bar', "hello", 'my private key', { whitelist: whitelist })
25
+ expect(request).to have_been_made
26
+ end
27
+
17
28
  end
18
29
 
19
30
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: faye-authentication
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.10.0
4
+ version: 1.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adrien Siami
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-09-12 00:00:00.000000000 Z
11
+ date: 2019-09-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jwt