faye-authentication 1.11.0 → 1.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 23d0511cded90a176f335c918ddd7ac42559d80306818da3505dbc24341b24f8
4
- data.tar.gz: 3aaaa3a5e286ee2952b0098b86c6d8d10aeb84c448f606044d406baeec6d074f
3
+ metadata.gz: 9e267e9258a90f6c713835fa6f1f17409d717258f2e6b0d8c7aaed6b085c857b
4
+ data.tar.gz: 0c358ecf0dc7f03e21d61af1b172d7a3d9335f4fc9dc4a39d6499d8db8d1be71
5
5
  SHA512:
6
- metadata.gz: 1e5e77a5ee7df63d0a0c62e813431baa690d16b5532a2f10494e72ca998b4393fa50f5f21adfff356c608892974a1c8b7e0fa0133d502577ef8919922df65511
7
- data.tar.gz: d2bcf4df68befe130af88a1e3a94a566374257385e8b737f16c76f22a70f8a042b15d2a205302bbad658e271ad97ce16a3021b25453263ae5f672612038a0375
6
+ metadata.gz: d4a7e752c492860afb8fb7cda7e52a1a33be80a4db3f004526b35e5a4c0cb62b596248ec288c74d346b559048a425d2e62f65ca6edaca56344208c22ac0e57c5
7
+ data.tar.gz: 3fe4f26c9ad2a1a83e8b8902ed60e55f3edbd46460b43a805390f28ecb61a684d2680ed729146448ce87260153b73d341604e6a33bde580fff63e9b6ad9a9eb3
data/.gitignore CHANGED
@@ -2,6 +2,7 @@
2
2
  *.rbc
3
3
  .bundle
4
4
  .config
5
+ .ruby-version
5
6
  .yardoc
6
7
  Gemfile.lock
7
8
  InstalledFiles
@@ -1,4 +1,5 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.1.2
4
- - 1.9.3
3
+ - 2.6.5
4
+ - 2.5.7
5
+ - 2.4.9
@@ -1,3 +1,10 @@
1
+ ## 1.12
2
+ - No longer retry and fetch a new signature after errors unrelated to `Faye::Authentication` (#15)
3
+ - Internal:
4
+ - Fix rspec and jasmine specs (#14)
5
+ - Replace `phantomjs` with `chromeheadless` for jasmine specs (#14)
6
+ - Updated Travis settings with last ruby versions (#14)
7
+
1
8
  ## 1.11.0
2
9
  - Optional authentication for `Faye::Authentication::HTTPClient` (#12)
3
10
 
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Faye::Authentication [![Build Status](https://travis-ci.org/dimelo/faye-authentication.svg?branch=master)](https://travis-ci.org/dimelo/faye-authentication) [![Code Climate](https://codeclimate.com/github/dimelo/faye-authentication.png)](https://codeclimate.com/github/dimelo/faye-authentication)
1
+ # Faye::Authentication [![Build Status](https://travis-ci.org/jarthod/faye-authentication.svg?branch=master)](https://travis-ci.org/dimelo/faye-authentication)
2
2
 
3
3
  Authentification implementation for faye
4
4
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.11.0
1
+ 1.12
@@ -8,6 +8,7 @@ function FayeAuthentication(client, endpoint, options) {
8
8
  this._waiting_signatures = [];
9
9
  this._timer = null;
10
10
  this.logger = Faye.logger;
11
+ this.ERROR_LIST = ['Expired signature', 'Required argument not signed', 'Invalid signature']
11
12
  }
12
13
 
13
14
  FayeAuthentication.prototype.endpoint = function() {
@@ -34,14 +35,14 @@ FayeAuthentication.prototype.resolveWaitingSignatures = function() {
34
35
  return (e.channel == params.channel && e.clientId == params.clientId);
35
36
  })[0];
36
37
  if (typeof signature === 'undefined') {
37
- self.logger.error('No signature found in ajax reply for channel ' + params.channel + ' and clientId ' + params.clientId);
38
+ self.logger.error('[Faye] No signature found in ajax reply for channel ' + params.channel + ' and clientId ' + params.clientId);
38
39
  } else if (signature && !signature.signature) {
39
- self.logger.error('Error when fetching signature for channel ' + params.channel + ' and clientId ' + params.clientId + ', error was : "' + signature.error + '"');
40
+ self.logger.error('[Faye] Error when fetching signature for channel ' + params.channel + ' and clientId ' + params.clientId + ', error was : "' + signature.error + '"');
40
41
  }
41
42
  FayeAuthentication.Promise.resolve(self._signatures[params.clientId][params.channel], signature ? signature.signature : null);
42
43
  });
43
44
  }, 'json').fail(function(xhr, textStatus, e) {
44
- self.logger.error('Failure when trying to fetch JWT signature for data "' + JSON.stringify(messages) + '", error was : ' + textStatus);
45
+ self.logger.error('[Faye] Failure when trying to fetch JWT signature for data "' + JSON.stringify(messages) + '", error was : ' + textStatus);
45
46
  $.each(messages, function(key, params) {
46
47
  FayeAuthentication.Promise.resolve(self._signatures[params.clientId][params.channel], null);
47
48
  });
@@ -96,7 +97,7 @@ FayeAuthentication.prototype.authentication_required = function(message) {
96
97
  try {
97
98
  return (!this._options.whitelist(subscription_or_channel));
98
99
  } catch (e) {
99
- this.logger.error("Error caught when evaluating whitelist function : " + e.message);
100
+ this.logger.error("[Faye] Error caught when evaluating whitelist function : " + e.message);
100
101
  }
101
102
  }
102
103
  return (true);
@@ -106,7 +107,7 @@ FayeAuthentication.prototype.authentication_required = function(message) {
106
107
 
107
108
  FayeAuthentication.prototype.incoming = function(message, callback) {
108
109
  var outbox_message = this._outbox[message.id];
109
- if (outbox_message && message.error) {
110
+ if (outbox_message && message.error && this.ERROR_LIST.indexOf(message.error) != -1) {
110
111
  var channel = outbox_message.message.subscription || outbox_message.message.channel;
111
112
  this._signatures[outbox_message.clientId][channel] = null;
112
113
  outbox_message.message.retried = true;
@@ -6,11 +6,11 @@ require 'faye/authentication/version'
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "faye-authentication"
8
8
  spec.version = Faye::Authentication::VERSION
9
- spec.authors = ["Adrien Siami"]
10
- spec.email = ["adrien.siami@dimelo.com"]
9
+ spec.authors = ["Adrien Siami", "Adrien Rey-Jarthon", "Cyril Le Roy", "Fabien Chaynes"]
10
+ spec.email = ["adrien.siami@gmail.com", "jobs@adrienjarthon.com", "cyril.leroy44@gmail.com", "fabien.chaynes@ringcentral.com"]
11
11
  spec.summary =
12
12
  spec.description = "A faye extension to add authentication mechanisms"
13
- spec.homepage = "https://github.com/dimelo/faye-authentication"
13
+ spec.homepage = "https://github.com/jarthod/faye-authentication"
14
14
  spec.license = "MIT"
15
15
 
16
16
  spec.files = `git ls-files -z`.split("\x0")
@@ -21,12 +21,13 @@ Gem::Specification.new do |spec|
21
21
  spec.add_runtime_dependency 'jwt', '>= 1.2'
22
22
  spec.add_runtime_dependency 'faye', '>= 1.0'
23
23
 
24
- spec.add_development_dependency "bundler", "~> 1.5"
25
- spec.add_development_dependency "rake", '~> 10.3'
26
- spec.add_development_dependency 'rspec', '~> 3.0'
27
- spec.add_development_dependency 'rspec-eventmachine', '~> 0.2'
28
- spec.add_development_dependency 'jasmine', '~> 2.0'
29
- spec.add_development_dependency 'rack', '~> 1.5'
30
- spec.add_development_dependency 'thin', '~> 1.6'
31
- spec.add_development_dependency 'webmock', '~> 1.18'
24
+ spec.add_development_dependency 'bundler'
25
+ spec.add_development_dependency 'rake'
26
+ spec.add_development_dependency 'rspec'
27
+ spec.add_development_dependency 'rspec-eventmachine'
28
+ spec.add_development_dependency 'jasmine'
29
+ spec.add_development_dependency 'chrome_remote'
30
+ spec.add_development_dependency 'rack'
31
+ spec.add_development_dependency 'thin'
32
+ spec.add_development_dependency 'webmock'
32
33
  end
@@ -27,8 +27,8 @@ describe('faye-authentication', function() {
27
27
  describe('authentication_required', function() {
28
28
 
29
29
  beforeEach(function() {
30
+ Faye.logger = {error: function() {}};
30
31
  this.auth = new FayeAuthentication(new Faye.Client('http://example.com'));
31
- Faye.logger = null;
32
32
  });
33
33
 
34
34
  function sharedExamplesForSubscribeAndPublish() {
@@ -45,7 +45,6 @@ describe('faye-authentication', function() {
45
45
 
46
46
  it('logs error if the function throws', function() {
47
47
  this.auth._options.whitelist = function(message) { throw new Error("boom"); }
48
- Faye.logger = {error: function() {}};
49
48
  spyOn(Faye.logger, 'error');
50
49
  this.auth.authentication_required(this.message);
51
50
  expect(Faye.logger.error).toHaveBeenCalledWith('[Faye] Error caught when evaluating whitelist function : boom');
@@ -1,5 +1,6 @@
1
1
  describe('Faye extension', function() {
2
2
  beforeEach(function() {
3
+ Faye.logger = {error: function() {}};
3
4
  this.client = new Faye.Client('http://localhost:9296/faye');
4
5
  jasmine.Ajax.install();
5
6
  });
@@ -10,13 +11,15 @@ describe('Faye extension', function() {
10
11
 
11
12
  describe('Without extension', function() {
12
13
  it('fails to subscribe', function(done) {
13
- this.client.subscribe('/foobar').then(undefined, function() {
14
+ this.client.subscribe('/foobar').then(undefined, function(e) {
15
+ expect(e.message).toBe('Invalid signature')
14
16
  done();
15
17
  });
16
18
  });
17
19
 
18
20
  it('fails to publish', function(done) {
19
- this.client.publish('/foobar', {text: 'whatever'}).then(undefined, function() {
21
+ this.client.publish('/foobar', {text: 'whatever'}).then(undefined, function(e) {
22
+ expect(e.message).toBe('Invalid signature')
20
23
  done();
21
24
  });
22
25
  });
@@ -71,7 +74,6 @@ describe('Faye extension', function() {
71
74
  this.dispatcher = {connectionType: "fake", clientId: '1234', sendMessage: function() {}, selectTransport: function() { }};
72
75
  spyOn(this.dispatcher, 'sendMessage');
73
76
  spyOn(this.dispatcher, 'selectTransport');
74
- Faye.extend(this.dispatcher, Faye.Publisher)
75
77
  });
76
78
 
77
79
  it('should add the signature to subscribe message', function(done) {
@@ -318,5 +320,44 @@ describe('Faye extension', function() {
318
320
 
319
321
  });
320
322
 
323
+ it('does not retry if the error is unrelated to authentication', function(done) {
324
+ other_client = new Faye.Client('http://localhost:9296/faye');
325
+ auth_extension = new FayeAuthentication(other_client, null, { retry_delay: 100 });
326
+ tweak_extension = {
327
+ incoming: function(message, callback) {
328
+ console.log('message',message)
329
+ if (message.error) {
330
+ message.error = 'Not an Authentication error';
331
+ }
332
+ callback(message);
333
+ }
334
+ }
335
+ other_client.addExtension(tweak_extension);
336
+ other_client.addExtension(this.extension);
337
+
338
+ jasmine.Ajax.stubRequest('/faye/auth').andReturn({
339
+ 'responseText': '{"signature": "bad"}'
340
+ });
341
+
342
+ var finished = false;
343
+ other_client.subscribe('/toto').then(undefined, function() {
344
+ finished = true;
345
+ });
346
+
347
+ setTimeout(function() {
348
+
349
+ // Initial 200ms batching delay
350
+
351
+ setTimeout(function() {
352
+ expect(finished).toBe(true);
353
+ }, 200 + 80); // 2nd Batching delay + 80 ms
354
+
355
+ setTimeout(function() {
356
+ expect(finished).toBe(true);
357
+ done();
358
+ }, 200 + 200); // 2nd Batching delay + 200 ms
359
+ }, 200);
360
+ });
361
+
321
362
  });
322
363
  });
@@ -1,13 +1,10 @@
1
1
  #Use this file to set/override Jasmine configuration options
2
2
  #You can remove it if you don't need it.
3
3
  #This file is loaded *after* jasmine.yml is interpreted.
4
- #
5
- #Example: using a different boot file.
6
- #Jasmine.configure do |config|
7
- # config.boot_dir = '/absolute/path/to/boot_dir'
8
- # config.boot_files = lambda { ['/absolute/path/to/boot_dir/file.js'] }
9
- #end
10
- #
4
+
5
+ Jasmine.configure do |config|
6
+ config.runner_browser = :chromeheadless
7
+ end
11
8
 
12
9
  require 'faye'
13
10
  require 'faye/authentication'
metadata CHANGED
@@ -1,14 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: faye-authentication
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.11.0
4
+ version: '1.12'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adrien Siami
8
+ - Adrien Rey-Jarthon
9
+ - Cyril Le Roy
10
+ - Fabien Chaynes
8
11
  autorequire:
9
12
  bindir: bin
10
13
  cert_chain: []
11
- date: 2019-09-16 00:00:00.000000000 Z
14
+ date: 2020-02-21 00:00:00.000000000 Z
12
15
  dependencies:
13
16
  - !ruby/object:Gem::Dependency
14
17
  name: jwt
@@ -42,117 +45,134 @@ dependencies:
42
45
  name: bundler
43
46
  requirement: !ruby/object:Gem::Requirement
44
47
  requirements:
45
- - - "~>"
48
+ - - ">="
46
49
  - !ruby/object:Gem::Version
47
- version: '1.5'
50
+ version: '0'
48
51
  type: :development
49
52
  prerelease: false
50
53
  version_requirements: !ruby/object:Gem::Requirement
51
54
  requirements:
52
- - - "~>"
55
+ - - ">="
53
56
  - !ruby/object:Gem::Version
54
- version: '1.5'
57
+ version: '0'
55
58
  - !ruby/object:Gem::Dependency
56
59
  name: rake
57
60
  requirement: !ruby/object:Gem::Requirement
58
61
  requirements:
59
- - - "~>"
62
+ - - ">="
60
63
  - !ruby/object:Gem::Version
61
- version: '10.3'
64
+ version: '0'
62
65
  type: :development
63
66
  prerelease: false
64
67
  version_requirements: !ruby/object:Gem::Requirement
65
68
  requirements:
66
- - - "~>"
69
+ - - ">="
67
70
  - !ruby/object:Gem::Version
68
- version: '10.3'
71
+ version: '0'
69
72
  - !ruby/object:Gem::Dependency
70
73
  name: rspec
71
74
  requirement: !ruby/object:Gem::Requirement
72
75
  requirements:
73
- - - "~>"
76
+ - - ">="
74
77
  - !ruby/object:Gem::Version
75
- version: '3.0'
78
+ version: '0'
76
79
  type: :development
77
80
  prerelease: false
78
81
  version_requirements: !ruby/object:Gem::Requirement
79
82
  requirements:
80
- - - "~>"
83
+ - - ">="
81
84
  - !ruby/object:Gem::Version
82
- version: '3.0'
85
+ version: '0'
83
86
  - !ruby/object:Gem::Dependency
84
87
  name: rspec-eventmachine
85
88
  requirement: !ruby/object:Gem::Requirement
86
89
  requirements:
87
- - - "~>"
90
+ - - ">="
88
91
  - !ruby/object:Gem::Version
89
- version: '0.2'
92
+ version: '0'
90
93
  type: :development
91
94
  prerelease: false
92
95
  version_requirements: !ruby/object:Gem::Requirement
93
96
  requirements:
94
- - - "~>"
97
+ - - ">="
95
98
  - !ruby/object:Gem::Version
96
- version: '0.2'
99
+ version: '0'
97
100
  - !ruby/object:Gem::Dependency
98
101
  name: jasmine
99
102
  requirement: !ruby/object:Gem::Requirement
100
103
  requirements:
101
- - - "~>"
104
+ - - ">="
102
105
  - !ruby/object:Gem::Version
103
- version: '2.0'
106
+ version: '0'
104
107
  type: :development
105
108
  prerelease: false
106
109
  version_requirements: !ruby/object:Gem::Requirement
107
110
  requirements:
108
- - - "~>"
111
+ - - ">="
109
112
  - !ruby/object:Gem::Version
110
- version: '2.0'
113
+ version: '0'
114
+ - !ruby/object:Gem::Dependency
115
+ name: chrome_remote
116
+ requirement: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - ">="
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
121
+ type: :development
122
+ prerelease: false
123
+ version_requirements: !ruby/object:Gem::Requirement
124
+ requirements:
125
+ - - ">="
126
+ - !ruby/object:Gem::Version
127
+ version: '0'
111
128
  - !ruby/object:Gem::Dependency
112
129
  name: rack
113
130
  requirement: !ruby/object:Gem::Requirement
114
131
  requirements:
115
- - - "~>"
132
+ - - ">="
116
133
  - !ruby/object:Gem::Version
117
- version: '1.5'
134
+ version: '0'
118
135
  type: :development
119
136
  prerelease: false
120
137
  version_requirements: !ruby/object:Gem::Requirement
121
138
  requirements:
122
- - - "~>"
139
+ - - ">="
123
140
  - !ruby/object:Gem::Version
124
- version: '1.5'
141
+ version: '0'
125
142
  - !ruby/object:Gem::Dependency
126
143
  name: thin
127
144
  requirement: !ruby/object:Gem::Requirement
128
145
  requirements:
129
- - - "~>"
146
+ - - ">="
130
147
  - !ruby/object:Gem::Version
131
- version: '1.6'
148
+ version: '0'
132
149
  type: :development
133
150
  prerelease: false
134
151
  version_requirements: !ruby/object:Gem::Requirement
135
152
  requirements:
136
- - - "~>"
153
+ - - ">="
137
154
  - !ruby/object:Gem::Version
138
- version: '1.6'
155
+ version: '0'
139
156
  - !ruby/object:Gem::Dependency
140
157
  name: webmock
141
158
  requirement: !ruby/object:Gem::Requirement
142
159
  requirements:
143
- - - "~>"
160
+ - - ">="
144
161
  - !ruby/object:Gem::Version
145
- version: '1.18'
162
+ version: '0'
146
163
  type: :development
147
164
  prerelease: false
148
165
  version_requirements: !ruby/object:Gem::Requirement
149
166
  requirements:
150
- - - "~>"
167
+ - - ">="
151
168
  - !ruby/object:Gem::Version
152
- version: '1.18'
169
+ version: '0'
153
170
  description: A faye extension to add authentication mechanisms
154
171
  email:
155
- - adrien.siami@dimelo.com
172
+ - adrien.siami@gmail.com
173
+ - jobs@adrienjarthon.com
174
+ - cyril.leroy44@gmail.com
175
+ - fabien.chaynes@ringcentral.com
156
176
  executables: []
157
177
  extensions: []
158
178
  extra_rdoc_files: []
@@ -160,6 +180,7 @@ files:
160
180
  - ".drone.yml"
161
181
  - ".gitignore"
162
182
  - ".rspec"
183
+ - ".ruby-version"
163
184
  - ".travis.yml"
164
185
  - CHANGELOG.md
165
186
  - Gemfile
@@ -190,7 +211,7 @@ files:
190
211
  - spec/utils/javascripts/jwt.js
191
212
  - spec/utils/javascripts/mock-ajax.js
192
213
  - spec/utils/javascripts/query-string.js
193
- homepage: https://github.com/dimelo/faye-authentication
214
+ homepage: https://github.com/jarthod/faye-authentication
194
215
  licenses:
195
216
  - MIT
196
217
  metadata: {}