dhc 2.3.0 → 2.4.0
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 +4 -4
- data/README.md +2 -2
- data/lib/dhc/interceptors/auth.rb +1 -0
- data/lib/dhc/version.rb +1 -1
- data/spec/interceptors/auth/bearer_spec.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9547c0b934f2ac6841be72e6f63213dc50d005c6f8559909869dd2ecb12e1e60
|
4
|
+
data.tar.gz: 3b7335a60aaffe92da269dd0a8fb7a51e66471136a506f0ae4de651a2ac95d8d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 39ed2e1baec1153872532441114157e7c7170f76746c4f8e9f77b585c36d0999f3047298d05daee2128dd13b74f21c87ba7b3822bbc703c5aa0c4da390511f4f
|
7
|
+
data.tar.gz: 9a6ae9ca323bf5d69d1668e72ceaa5969d79e2dc315a575df805b53d48c24321f537d6ab135d4e1412840cc52c7d400e71fbf121b985fe9eefbc86dfd38f7e91
|
data/README.md
CHANGED
@@ -475,7 +475,7 @@ Assuming the method `access_token` responds on runtime of the request with `1234
|
|
475
475
|
|
476
476
|
If you configure `expires_at` and `refresh` proc in addition to `bearer`, DHC will refresh the bearer token using the defined `refresh` proc in two cases:
|
477
477
|
|
478
|
-
1. before the request if `expires_at` < `DateTime.now + 1.minute`
|
478
|
+
1. before the request if `expires_at.call` < `DateTime.now + 1.minute`
|
479
479
|
2. if the request fails and `refresh(response)` responds to true
|
480
480
|
|
481
481
|
```ruby
|
@@ -489,7 +489,7 @@ refresh = ->(response = nil){
|
|
489
489
|
end
|
490
490
|
}
|
491
491
|
|
492
|
-
DHC.get('http://depay.fi', auth: { bearer: -> { session[:access_token] }, refresh: refresh, expires_at:
|
492
|
+
DHC.get('http://depay.fi', auth: { bearer: -> { session[:access_token] }, refresh: refresh, expires_at: -> { session[:expires_at] } })
|
493
493
|
```
|
494
494
|
|
495
495
|
##### Basic Authentication
|
data/lib/dhc/version.rb
CHANGED
@@ -50,14 +50,14 @@ describe DHC::Auth do
|
|
50
50
|
|
51
51
|
it 'refreshes the bearer if it expired' do
|
52
52
|
stub_request(:get, 'http://depay.fi/').with(headers: { 'Authorization' => 'Bearer 2_ACCESS_TOKEN' })
|
53
|
-
DHC.get('http://depay.fi', auth: { bearer: -> { session[:access_token] }, refresh: refresh, expires_at: (DateTime.now - 1.minute).to_s })
|
53
|
+
DHC.get('http://depay.fi', auth: { bearer: -> { session[:access_token] }, refresh: refresh, expires_at: -> { (DateTime.now - 1.minute).to_s } })
|
54
54
|
end
|
55
55
|
|
56
56
|
it 'can evaluate response errors (like unauthorized) inside the refresh proc' do
|
57
57
|
stub_request(:get, 'http://depay.fi/').with(headers: { 'Authorization' => 'Bearer 2_ACCESS_TOKEN' })
|
58
58
|
.to_return(status: 401, body: { "error_code": 'ACCESS_TOKEN_EXPIRED' }.to_json)
|
59
59
|
stub_request(:get, 'http://depay.fi/').with(headers: { 'Authorization' => 'Bearer 3_ACCESS_TOKEN' })
|
60
|
-
DHC.get('http://depay.fi', auth: { bearer: -> { session[:access_token] }, refresh: refresh, expires_at: (DateTime.now - 1.minute).to_s })
|
60
|
+
DHC.get('http://depay.fi', auth: { bearer: -> { session[:access_token] }, refresh: refresh, expires_at: -> { (DateTime.now - 1.minute).to_s } })
|
61
61
|
end
|
62
62
|
end
|
63
63
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dhc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- https://github.com/DePayFi/dhc/contributors
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-02-
|
11
|
+
date: 2023-02-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|