Skip to content

Commit c734a88

Browse files
committed
Use for https url
1 parent a618e15 commit c734a88

7 files changed

Lines changed: 42 additions & 42 deletions

File tree

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ Authorization = APIAuth "#{client access id}:#{signature from step 2}"
4848
A cURL request would look like:
4949

5050
```sh
51-
curl -X POST --header 'Content-Type: application/json' --header "Date: Tue, 30 May 2017 03:51:43 GMT" --header "Authorization: ${AUTHORIZATION}" http://my-app.com/request_path`
51+
curl -X POST --header 'Content-Type: application/json' --header "Date: Tue, 30 May 2017 03:51:43 GMT" --header "Authorization: ${AUTHORIZATION}" https://my-app.com/request_path`
5252
```
5353

5454
5. On the server side, the SHA2 HMAC is computed in the same way using the
@@ -60,10 +60,10 @@ minutes in order to avoid replay attacks.
6060

6161
## References
6262

63-
* [Hash functions](http://en.wikipedia.org/wiki/Cryptographic_hash_function)
64-
* [SHA-2 Hash function](http://en.wikipedia.org/wiki/SHA-2)
65-
* [HMAC algorithm](http://en.wikipedia.org/wiki/HMAC)
66-
* [RFC 2104 (HMAC)](http://tools.ietf.org/html/rfc2104)
63+
* [Hash functions](https://en.wikipedia.org/wiki/Cryptographic_hash_function)
64+
* [SHA-2 Hash function](https://en.wikipedia.org/wiki/SHA-2)
65+
* [HMAC algorithm](https://en.wikipedia.org/wiki/HMAC)
66+
* [RFC 2104 (HMAC)](https://tools.ietf.org/html/rfc2104)
6767

6868
## Requirement
6969

@@ -285,9 +285,9 @@ the public methods for each driver are required to be implemented by your driver
285285
286286
## Authors
287287
288-
* [Mauricio Gomes](http://github.com/mgomes)
289-
* [Kevin Glowacz](http://github.com/kjg)
290-
* [Florian Wininger](http://github.com/fwininger)
288+
* [Mauricio Gomes](https://github.com/mgomes)
289+
* [Kevin Glowacz](https://github.com/kjg)
290+
* [Florian Wininger](https://github.com/fwininger)
291291
292292
## Copyright
293293

spec/api_auth_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def hmac(secret_key, request, canonical_string = nil, digest = 'sha1')
2424
end
2525

2626
describe '.sign!' do
27-
let(:request) { RestClient::Request.new(url: 'http://google.com', method: :get) }
27+
let(:request) { RestClient::Request.new(url: 'https://google.com', method: :get) }
2828
let(:headers) { ApiAuth::Headers.new(request) }
2929

3030
it 'generates date header before signing' do
@@ -182,7 +182,7 @@ def hmac(secret_key, request, canonical_string = nil, digest = 'sha1')
182182
context 'normal APIAuth Auth header' do
183183
let(:request) do
184184
RestClient::Request.new(
185-
url: 'http://google.com',
185+
url: 'https://google.com',
186186
method: :get,
187187
headers: { authorization: 'APIAuth 1044:aGVsbG8gd29ybGQ=' }
188188
)
@@ -196,7 +196,7 @@ def hmac(secret_key, request, canonical_string = nil, digest = 'sha1')
196196
context 'Corporate prefixed APIAuth header' do
197197
let(:request) do
198198
RestClient::Request.new(
199-
url: 'http://google.com',
199+
url: 'https://google.com',
200200
method: :get,
201201
headers: { authorization: 'Corporate APIAuth 1044:aGVsbG8gd29ybGQ=' }
202202
)

spec/headers_spec.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
let(:uri) { '' }
99

1010
context 'uri with just host without /' do
11-
let(:uri) { 'http://google.com'.freeze }
11+
let(:uri) { 'https://google.com'.freeze }
1212

1313
it 'return / as canonical string path' do
1414
expect(subject.canonical_string).to eq('GET,,,/,')
@@ -20,7 +20,7 @@
2020
end
2121

2222
context 'uri with host and /' do
23-
let(:uri) { 'http://google.com/'.freeze }
23+
let(:uri) { 'https://google.com/'.freeze }
2424

2525
it 'return / as canonical string path' do
2626
expect(subject.canonical_string).to eq('GET,,,/,')
@@ -31,8 +31,8 @@
3131
end
3232
end
3333

34-
context 'uri has a string matching http:// in it' do
35-
let(:uri) { 'http://google.com/?redirect_to=https://www.example.com'.freeze }
34+
context 'uri has a string matching https:// in it' do
35+
let(:uri) { 'https://google.com/?redirect_to=https://www.example.com'.freeze }
3636

3737
it 'return /?redirect_to=https://www.example.com as canonical string path' do
3838
expect(subject.canonical_string).to eq('GET,,,/?redirect_to=https://www.example.com,')
@@ -46,7 +46,7 @@
4646

4747
context 'string construction' do
4848
context 'with a driver that supplies http_method' do
49-
let(:request) { RestClient::Request.new(url: 'http://google.com', method: :get) }
49+
let(:request) { RestClient::Request.new(url: 'https://google.com', method: :get) }
5050
subject(:headers) { described_class.new(request) }
5151
let(:driver) { headers.instance_variable_get('@request') }
5252

@@ -161,7 +161,7 @@
161161
context 'no content hash already calculated' do
162162
let(:request) do
163163
RestClient::Request.new(
164-
url: 'http://google.com',
164+
url: 'https://google.com',
165165
method: :post,
166166
payload: "hello\nworld"
167167
)
@@ -176,7 +176,7 @@
176176
context 'hash already calculated' do
177177
let(:request) do
178178
RestClient::Request.new(
179-
url: 'http://google.com',
179+
url: 'https://google.com',
180180
method: :post,
181181
payload: "hello\nworld",
182182
headers: { 'X-Authorization-Content-SHA256' => 'abcd' }
@@ -191,7 +191,7 @@
191191
end
192192

193193
describe '#content_hash_mismatch?' do
194-
let(:request) { RestClient::Request.new(url: 'http://google.com', method: :get) }
194+
let(:request) { RestClient::Request.new(url: 'https://google.com', method: :get) }
195195
subject(:headers) { described_class.new(request) }
196196
let(:driver) { headers.instance_variable_get('@request') }
197197

spec/railtie_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def generated_request
116116
describe 'Rails ActiveResource integration' do
117117
class TestResource < ActiveResource::Base
118118
with_api_auth '1044', API_KEY_STORE['1044']
119-
self.site = 'http://localhost/'
119+
self.site = 'https://localhost/'
120120
self.format = :xml
121121
end
122122

spec/request_drivers/http_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
end
1414

1515
let(:verb) { :put }
16-
let(:uri) { 'http://localhost/resource.xml?foo=bar&bar=foo' }
16+
let(:uri) { 'https://localhost/resource.xml?foo=bar&bar=foo' }
1717
let(:body) { "hello\nworld" }
1818

1919
let(:headers) do

spec/request_drivers/httpi_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
let(:timestamp) { Time.now.utc.httpdate }
55

66
let(:request) do
7-
httpi_request = HTTPI::Request.new('http://localhost/resource.xml?foo=bar&bar=foo')
7+
httpi_request = HTTPI::Request.new('https://localhost/resource.xml?foo=bar&bar=foo')
88
httpi_request.headers.merge!('Authorization' => 'APIAuth 1044:12345',
99
'X-Authorization-Content-SHA256' => '47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=',
1010
'content-type' => 'text/plain',
@@ -56,7 +56,7 @@
5656

5757
describe 'setting headers correctly' do
5858
let(:request) do
59-
httpi_request = HTTPI::Request.new('http://localhost/resource.xml?foo=bar&bar=foo')
59+
httpi_request = HTTPI::Request.new('https://localhost/resource.xml?foo=bar&bar=foo')
6060
httpi_request.headers['content-type'] = 'text/plain'
6161
httpi_request
6262
end

spec/request_drivers/rest_client_spec.rb

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
describe ApiAuth::RequestDrivers::RestClientRequest do
44
let(:timestamp) { Time.now.utc.httpdate }
55

6-
let(:request_path) { 'http://localhost/resource.xml?foo=bar&bar=foo' }
6+
let(:request_path) { 'https://localhost/resource.xml?foo=bar&bar=foo' }
77

88
let(:request_headers) do
99
{
@@ -16,7 +16,7 @@
1616

1717
let(:request) do
1818
RestClient::Request.new(
19-
url: 'http://localhost/resource.xml?foo=bar&bar=foo',
19+
url: 'https://localhost/resource.xml?foo=bar&bar=foo',
2020
headers: request_headers,
2121
method: :put,
2222
payload: "hello\nworld"
@@ -35,7 +35,7 @@
3535
end
3636

3737
it 'gets the request_uri' do
38-
expect(driven_request.request_uri).to eq('http://localhost/resource.xml?foo=bar&bar=foo')
38+
expect(driven_request.request_uri).to eq('https://localhost/resource.xml?foo=bar&bar=foo')
3939
end
4040

4141
it 'gets the timestamp' do
@@ -53,7 +53,7 @@
5353

5454
it 'treats no body as empty string' do
5555
request = RestClient::Request.new(
56-
url: 'http://localhost/resource.xml?foo=bar&bar=foo',
56+
url: 'https://localhost/resource.xml?foo=bar&bar=foo',
5757
headers: request_headers,
5858
method: :put
5959
)
@@ -66,7 +66,7 @@
6666
context 'when put request' do
6767
let(:request) do
6868
RestClient::Request.new(
69-
url: 'http://localhost/resource.xml?foo=bar&bar=foo',
69+
url: 'https://localhost/resource.xml?foo=bar&bar=foo',
7070
headers: request_headers,
7171
method: :put
7272
)
@@ -80,7 +80,7 @@
8080
context 'when get request' do
8181
let(:request) do
8282
RestClient::Request.new(
83-
url: 'http://localhost/resource.xml?foo=bar&bar=foo',
83+
url: 'https://localhost/resource.xml?foo=bar&bar=foo',
8484
headers: request_headers,
8585
method: :get
8686
)
@@ -104,7 +104,7 @@
104104
context 'when getting' do
105105
let(:request) do
106106
RestClient::Request.new(
107-
url: 'http://localhost/resource.xml?foo=bar&bar=foo',
107+
url: 'https://localhost/resource.xml?foo=bar&bar=foo',
108108
headers: request_headers,
109109
method: :get
110110
)
@@ -119,7 +119,7 @@
119119
context 'when posting' do
120120
let(:request) do
121121
RestClient::Request.new(
122-
url: 'http://localhost/resource.xml?foo=bar&bar=foo',
122+
url: 'https://localhost/resource.xml?foo=bar&bar=foo',
123123
headers: request_headers,
124124
method: :post,
125125
payload: "hello\nworld"
@@ -140,7 +140,7 @@
140140
context 'when putting' do
141141
let(:request) do
142142
RestClient::Request.new(
143-
url: 'http://localhost/resource.xml?foo=bar&bar=foo',
143+
url: 'https://localhost/resource.xml?foo=bar&bar=foo',
144144
headers: request_headers,
145145
method: :put,
146146
payload: "hello\nworld"
@@ -161,7 +161,7 @@
161161
context 'when deleting' do
162162
let(:request) do
163163
RestClient::Request.new(
164-
url: 'http://localhost/resource.xml?foo=bar&bar=foo',
164+
url: 'https://localhost/resource.xml?foo=bar&bar=foo',
165165
headers: request_headers,
166166
method: :delete
167167
)
@@ -203,7 +203,7 @@
203203
context 'when getting' do
204204
let(:request) do
205205
RestClient::Request.new(
206-
url: 'http://localhost/resource.xml?foo=bar&bar=foo',
206+
url: 'https://localhost/resource.xml?foo=bar&bar=foo',
207207
headers: request_headers,
208208
method: :get
209209
)
@@ -217,7 +217,7 @@
217217
context 'when posting' do
218218
let(:request) do
219219
RestClient::Request.new(
220-
url: 'http://localhost/resource.xml?foo=bar&bar=foo',
220+
url: 'https://localhost/resource.xml?foo=bar&bar=foo',
221221
headers: request_headers,
222222
method: :post,
223223
payload: "hello\nworld"
@@ -258,7 +258,7 @@
258258
context 'when putting' do
259259
let(:request) do
260260
RestClient::Request.new(
261-
url: 'http://localhost/resource.xml?foo=bar&bar=foo',
261+
url: 'https://localhost/resource.xml?foo=bar&bar=foo',
262262
headers: request_headers,
263263
method: :put,
264264
payload: "hello\nworld"
@@ -299,7 +299,7 @@
299299
context 'when deleting' do
300300
let(:request) do
301301
RestClient::Request.new(
302-
url: 'http://localhost/resource.xml?foo=bar&bar=foo',
302+
url: 'https://localhost/resource.xml?foo=bar&bar=foo',
303303
headers: request_headers,
304304
method: :delete
305305
)
@@ -315,7 +315,7 @@
315315
context 'when getting' do
316316
let(:request) do
317317
RestClient::Request.new(
318-
url: 'http://localhost/resource.xml?foo=bar&bar=foo',
318+
url: 'https://localhost/resource.xml?foo=bar&bar=foo',
319319
method: :get
320320
)
321321
end
@@ -332,7 +332,7 @@
332332
context 'when posting' do
333333
let(:request) do
334334
RestClient::Request.new(
335-
url: 'http://localhost/resource.xml?foo=bar&bar=foo',
335+
url: 'https://localhost/resource.xml?foo=bar&bar=foo',
336336
method: :post,
337337
payload: "hello\nworld"
338338
)
@@ -350,7 +350,7 @@
350350
context 'when putting' do
351351
let(:request) do
352352
RestClient::Request.new(
353-
url: 'http://localhost/resource.xml?foo=bar&bar=foo',
353+
url: 'https://localhost/resource.xml?foo=bar&bar=foo',
354354
method: :put,
355355
payload: "hello\nworld"
356356
)
@@ -368,7 +368,7 @@
368368
context 'when deleting' do
369369
let(:request) do
370370
RestClient::Request.new(
371-
url: 'http://localhost/resource.xml?foo=bar&bar=foo',
371+
url: 'https://localhost/resource.xml?foo=bar&bar=foo',
372372
method: :delete
373373
)
374374
end
@@ -388,7 +388,7 @@
388388
headers = { 'X-Authorization-Content-SHA256' => 'e59ff97941044f85df5297e1c302d260',
389389
:content_type => 'text/plain',
390390
'Date' => 'Mon, 23 Jan 1984 03:29:56 GMT' }
391-
request = RestClient::Request.new(url: 'http://localhost/resource.xml?foo=bar&bar=foo',
391+
request = RestClient::Request.new(url: 'https://localhost/resource.xml?foo=bar&bar=foo',
392392
headers: headers,
393393
method: :put)
394394
ApiAuth.sign!(request, 'some access id', 'some secret key')

0 commit comments

Comments
 (0)