Skip to content

Commit 8b2f5b1

Browse files
author
Jon Elverkilde
authoredMar 23, 2021
Merge pull request #171 from pusher/ssl_is_default
Use TLS by default
2 parents e7a549d + 1947c09 commit 8b2f5b1

File tree

5 files changed

+118
-126
lines changed

5 files changed

+118
-126
lines changed
 

‎.github/workflows/release.yml

+2-5
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
sudo cp semver-tool-3.2.0/src/semver /usr/local/bin
4040
- name: Bump version
4141
run: |
42-
export CURRENT=$(gem info pusher-push-notifications --remote --exact | grep -o "pusher-push-notifications ([0-9]*\.[0-9]*\.[0-9]*)" | awk -F '[()]' '{print $2}')
42+
export CURRENT=$(gem info pusher --remote --exact | grep -o "pusher ([0-9]*\.[0-9]*\.[0-9]*)" | awk -F '[()]' '{print $2}')
4343
export NEW_VERSION=$(semver bump ${{ env.RELEASE }} $CURRENT)
4444
echo "VERSION=$NEW_VERSION" >> $GITHUB_ENV
4545
- name: Checkout code
@@ -63,12 +63,9 @@ jobs:
6363
- name: Prepare version.rb
6464
run: |
6565
sed -i "s|VERSION = '[^']*'|VERSION = '${{ env.VERSION }}'|" lib/pusher/version.rb
66-
- name: Prepare Gemfile.lock
67-
run: |
68-
sed -i "s|pusher-push-notifications ([^)]*)|pusher-push-notifications (${{ env.VERSION }})|" Gemfile.lock
6966
- name: Commit changes
7067
run: |
71-
git add CHANGELOG.md lib/pusher/push_notifications/version.rb Gemfile.lock
68+
git add CHANGELOG.md lib/pusher/version.rb
7269
git commit -m "Bump to version ${{ env.VERSION }}"
7370
- name: Push
7471
run: git push

‎CHANGELOG.md

+70-88
Original file line numberDiff line numberDiff line change
@@ -1,139 +1,121 @@
1-
1.4.3 / 2020-10-28
2-
==================
1+
# Changelog
2+
3+
## 2.0.0
4+
5+
* [CHANGED] Use TLS by default.
6+
* [REMOVED] Support for Ruby 2.4 and 2.5.
7+
* [FIXED] Handle empty or nil configuration.
8+
* [REMOVED] Legacy Push Notification integration.
9+
* [ADDED] Stalebot and Github actions.
10+
11+
## 1.4.3
312

4-
* Remove newline from end of base64 encoded strings, some decoders don't like
13+
* [FIXED] Remove newline from end of base64 encoded strings, some decoders don't like
514
them.
615

7-
1.4.2 / 2020-10-20
16+
## 1.4.2
817
==================
918

10-
* Return `shared_secret` to support authenticating encrypted channels. Thanks
19+
* [FIXED] Return `shared_secret` to support authenticating encrypted channels. Thanks
1120
@Benjaminpjacobs
1221

13-
1.4.1 / 2020-10-05
14-
==================
22+
## 1.4.1
1523

16-
* Remove rbnacl from dependencies so we don't get errors when it isn't
24+
* [CHANGED] Remove rbnacl from dependencies so we don't get errors when it isn't
1725
required. Thanks @y-yagi!
1826

19-
1.4.0 / 2020-09-29
20-
==================
27+
## 1.4.0
2128

22-
* Support for end-to-end encryption.
29+
* [ADDED] Support for end-to-end encryption.
2330

24-
1.3.3 / 2019-07-02
25-
==================
31+
## 1.3.3
2632

27-
* Rewording to clarify "Pusher Channels" or simply "Channels" product name.
33+
* [CHANGED] Rewording to clarify "Pusher Channels" or simply "Channels" product name.
2834

29-
1.3.2 / 2018-10-17
30-
==================
35+
## 1.3.2
3136

32-
* Return a specific error for "Request Entity Too Large" (body over 10KB).
33-
* Add a `use_tls` option for SSL (defaults to false).
34-
* Add a `from_url` client method (in addition to existing `from_env` option).
35-
* Improved documentation and fixed typos.
36-
* Add Ruby 2.4 to test matrix.
37+
* [FIXED] Return a specific error for "Request Entity Too Large" (body over 10KB).
38+
* [ADDED] Add a `use_tls` option for SSL (defaults to false).
39+
* [ADDED] Add a `from_url` client method (in addition to existing `from_env` option).
40+
* [CHANGED] Improved documentation and fixed typos.
41+
* [ADDED] Add Ruby 2.4 to test matrix.
3742

38-
1.3.1 / 2017-03-15
39-
==================
43+
## 1.3.1
4044

41-
* Added missing client batch methods to default client delegations
42-
* Document raised exception in the `authenticate` method
43-
* Fixes em-http-request from using v2.5.0 of `addressable` breaking builds.
45+
* [FIXED] Added missing client batch methods to default client delegations
46+
* [CHANGED] Document raised exception in the `authenticate` method
47+
* [FIXED] Fixes em-http-request from using v2.5.0 of `addressable` breaking builds.
4448

45-
1.3.0 / 2016-08-23
46-
==================
49+
## 1.3.0
4750

48-
* Add support for sending push notifications on up to 10 interests.
51+
* [ADDED] Add support for sending push notifications on up to 10 interests.
4952

50-
1.2.1 / 2016-08-22
51-
==================
53+
## 1.2.1
5254

53-
* Fixes Rails 5 compatibility. Use duck-typing to detect request object
55+
* [FIXED] Fixes Rails 5 compatibility. Use duck-typing to detect request object
5456

55-
1.2.0 / 2016-08-15
56-
==================
57+
## 1.2.0
5758

58-
* Minor release for Native notifications
59+
* [CHANGED] Minor release for Native notifications
5960

60-
1.2.0.rc1 / 2016-07-18
61-
==================
61+
## 1.2.0.rc1
6262

63-
* Add support for Native notifications
63+
* [ADDED] Add support for Native notifications
6464

65-
1.1.0 / 2016-05-20
66-
==================
65+
## 1.1.0
6766

68-
* Add support for batch events
67+
* [ADDED] Add support for batch events
6968

70-
1.0.0 / 2016-05-19
71-
==================
69+
## 1.0.0
7270

73-
No breaking changes, this release is just to follow semver and show that we
71+
* [CHANGED] No breaking changes, this release is just to follow semver and show that we
7472
are stable.
7573

76-
0.18.0 / 2016-05-15
77-
==================
74+
## 0.18.0
7875

79-
* Introduce `Pusher::Client.from_env`
80-
* Improve error handling on missing config
76+
* [ADDED] Introduce `Pusher::Client.from_env`
77+
* [FIXED] Improve error handling on missing config
8178

82-
0.17.0 / 2016-02-22
83-
==================
79+
## 0.17.0
8480

85-
* Introduce the `cluster` option.
81+
* [ADDED] Introduce the `cluster` option.
8682

87-
0.16.0 / 2016-01-21
88-
==================
83+
## 0.16.0
8984

90-
* Bump httpclient version to 2.7
91-
* Ruby 1.8.7 is not supported anymore.
85+
* [CHANGED] Bump httpclient version to 2.7
86+
* [REMOVED] Ruby 1.8.7 is not supported anymore.
9287

93-
0.15.2 / 2015-12-03
94-
==================
88+
## 0.15.2
9589

96-
* Documented `Pusher.channel_info`, `Pusher.channels`
97-
* Added `Pusher.channel_users`
90+
* [CHANGED] Documented `Pusher.channel_info`, `Pusher.channels`
91+
* [ADDED] Added `Pusher.channel_users`
9892

99-
0.15.1 / 2015-11-03
100-
==================
93+
## 0.15.1
10194

102-
* Fixed a bug where the `authenticate` method added in 0.15.0 wasn't exposed on the Pusher class.
95+
* [FIXED] Fixed a bug where the `authenticate` method added in 0.15.0 wasn't exposed on the Pusher class.
10396

104-
0.15.0 / 2015-11-02
105-
==================
97+
## 0.15.0
10698

107-
* Added `Pusher.authenticate` method for authenticating private and presence channels.
99+
* [ADDED] Added `Pusher.authenticate` method for authenticating private and presence channels.
108100
This is prefered over the older `Pusher['a_channel'].authenticate(...)` style.
109101

110-
0.14.6 / 2015-09-29
111-
==================
112-
* Updated to use the `pusher-signature` gem instead of `signature`.
113-
This resolves namespace related issues.
102+
## 0.14.6
114103

115-
0.14.5 / 2015-05-11
116-
==================
117-
118-
* SECURITY: Prevent auth delegation trough crafted socket IDs
119-
120-
0.14.4 / 2015-01-20
121-
==================
104+
* [CHANGED] Updated to use the `pusher-signature` gem instead of `signature`.
105+
This resolves namespace related issues.
122106

123-
* SECURITY: Prevent timing attack, update signature to v0.1.8
124-
* SECURITY: Prevent POODLE. Disable SSLv3, update httpclient to v2.5
125-
* Fix channel name character limit.
126-
* Adds support for listing users on a presence channel
107+
## 0.14.5
127108

128-
0.14.3 / 2015-01-20
129-
==================
109+
* [SECURITY] Prevent auth delegation trough crafted socket IDs
130110

131-
Yanked, bad release
111+
## 0.14.4
132112

133-
0.14.2 / 2014-10-16
134-
==================
113+
* [SECURITY] Prevent timing attack, update signature to v0.1.8
114+
* [SECURITY] Prevent POODLE. Disable SSLv3, update httpclient to v2.5
115+
* [FIXED] Fix channel name character limit.
116+
* [ADDED] Adds support for listing users on a presence channel
135117

136-
First release with a changelog !
118+
## 0.14.2
137119

138-
* Bump httpclient to v2.4. See #62 (POODLE SSL)
139-
* Fix limited channel count at README.md. Thanks @tricknotes
120+
* [CHANGED] Bump httpclient to v2.4. See #62 (POODLE SSL)
121+
* [CHANGED] Fix limited channel count at README.md. Thanks @tricknotes

‎lib/pusher/client.rb

+9-5
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,16 @@ def self.from_url(url)
2929
end
3030

3131
def initialize(options = {})
32-
@scheme = "http"
33-
@port = options[:port] || 80
32+
@scheme = "https"
33+
@port = options[:port] || 443
3434

35-
if options[:use_tls] || options[:encrypted]
36-
@scheme = "https"
37-
@port = options[:port] || 443
35+
if options.key?(:encrypted)
36+
warn "[DEPRECATION] `encrypted` is deprecated and will be removed in the next major version. Use `use_tls` instead."
37+
end
38+
39+
if options[:use_tls] == false || options[:encrypted] == false
40+
@scheme = "http"
41+
@port = options[:port] || 80
3842
end
3943

4044
@app_id = options[:app_id]

‎lib/pusher/version.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module Pusher
2-
VERSION = '1.4.3'
2+
VERSION = '2.0.0'
33
end

‎spec/client_spec.rb

+36-27
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
expect(@client.host).to eq('api-mt1.pusher.com')
2121
end
2222

23-
it 'should be preconfigured for port 80' do
24-
expect(@client.port).to eq(80)
23+
it 'should be preconfigured for port 443' do
24+
expect(@client.port).to eq(443)
2525
end
2626

2727
it 'should use standard logger if no other logger if defined' do
@@ -116,26 +116,26 @@
116116
end
117117

118118
describe 'configuring TLS' do
119-
it 'should set port and scheme if "use_tls" enabled' do
119+
it 'should set port and scheme if "use_tls" disabled' do
120120
client = Pusher::Client.new({
121-
:use_tls => true,
121+
:use_tls => false,
122122
})
123-
expect(client.scheme).to eq('https')
124-
expect(client.port).to eq(443)
123+
expect(client.scheme).to eq('http')
124+
expect(client.port).to eq(80)
125125
end
126126

127-
it 'should set port and scheme if "encrypted" enabled' do
127+
it 'should set port and scheme if "encrypted" disabled' do
128128
client = Pusher::Client.new({
129-
:encrypted => true,
129+
:encrypted => false,
130130
})
131-
expect(client.scheme).to eq('https')
132-
expect(client.port).to eq(443)
131+
expect(client.scheme).to eq('http')
132+
expect(client.port).to eq(80)
133133
end
134134

135-
it 'should use non-TLS port and scheme if "encrypted" or "use_tls" are not set' do
135+
it 'should use TLS port and scheme if "encrypted" or "use_tls" are not set' do
136136
client = Pusher::Client.new
137-
expect(client.scheme).to eq('http')
138-
expect(client.port).to eq(80)
137+
expect(client.scheme).to eq('https')
138+
expect(client.port).to eq(443)
139139
end
140140

141141
it 'should override port if "use_tls" option set but a different port is specified' do
@@ -147,6 +147,15 @@
147147
expect(client.port).to eq(8443)
148148
end
149149

150+
it 'should override port if "use_tls" option set but a different port is specified' do
151+
client = Pusher::Client.new({
152+
:use_tls => false,
153+
:port => 8000
154+
})
155+
expect(client.scheme).to eq('http')
156+
expect(client.port).to eq(8000)
157+
end
158+
150159
end
151160

152161
describe 'configuring a http proxy' do
@@ -535,15 +544,15 @@
535544

536545
let(:call_api) { @client.send(verb, '/path') }
537546

538-
it "should use http by default" do
547+
it "should use https by default" do
539548
call_api
540-
expect(WebMock).to have_requested(verb, %r{http://api-mt1.pusher.com/apps/20/path})
549+
expect(WebMock).to have_requested(verb, %r{https://api-mt1.pusher.com/apps/20/path})
541550
end
542551

543552
it "should use https if configured" do
544-
@client.encrypted = true
553+
@client.encrypted = false
545554
call_api
546-
expect(WebMock).to have_requested(verb, %r{https://api-mt1.pusher.com})
555+
expect(WebMock).to have_requested(verb, %r{http://api-mt1.pusher.com})
547556
end
548557

549558
it "should format the respose hash with symbols at first level" do
@@ -622,15 +631,15 @@
622631
}
623632
}
624633

625-
it "should use http by default" do
634+
it "should use https by default" do
626635
call_api
627-
expect(WebMock).to have_requested(verb, %r{http://api-mt1.pusher.com/apps/20/path})
636+
expect(WebMock).to have_requested(verb, %r{https://api-mt1.pusher.com/apps/20/path})
628637
end
629638

630-
it "should use https if configured" do
631-
@client.encrypted = true
639+
it "should use http if configured" do
640+
@client.encrypted = false
632641
call_api
633-
expect(WebMock).to have_requested(verb, %r{https://api-mt1.pusher.com})
642+
expect(WebMock).to have_requested(verb, %r{http://api-mt1.pusher.com})
634643
end
635644

636645
# Note that the raw httpclient connection object is returned and
@@ -657,20 +666,20 @@
657666

658667
let(:call_api) { @client.send(method, '/path') }
659668

660-
it "should use http by default" do
669+
it "should use https by default" do
661670
EM.run {
662671
call_api.callback {
663-
expect(WebMock).to have_requested(verb, %r{http://api-mt1.pusher.com/apps/20/path})
672+
expect(WebMock).to have_requested(verb, %r{https://api-mt1.pusher.com/apps/20/path})
664673
EM.stop
665674
}
666675
}
667676
end
668677

669-
it "should use https if configured" do
678+
it "should use http if configured" do
670679
EM.run {
671-
@client.encrypted = true
680+
@client.encrypted = false
672681
call_api.callback {
673-
expect(WebMock).to have_requested(verb, %r{https://api-mt1.pusher.com})
682+
expect(WebMock).to have_requested(verb, %r{http://api-mt1.pusher.com})
674683
EM.stop
675684
}
676685
}

0 commit comments

Comments
 (0)
Please sign in to comment.