warden-jwt 0.1.0 → 0.1.1
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/lib/warden/jwt/config.rb +6 -1
- data/lib/warden/jwt/strategy.rb +10 -7
- data/lib/warden/jwt/version.rb +1 -1
- data/spec/support/vcr.rb +1 -0
- data/spec/warden/jwt/config_spec.rb +19 -2
- data/spec/warden/jwt/strategy_spec.rb +14 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 86881b619ac70fde474bbc61fa642f4d80cecbef
|
4
|
+
data.tar.gz: bebf0a4300021b9ee6c12b8e60a881e3d32a2782
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 17b3bd3a9c65b064bb7adc5a06a937343c451316f60ea85b86d5337c4a3b0496a82e84eb9fc5ddd4ff1ee438e2cddf68c1fe165e6b906bbffb3eda75dc5e1eff
|
7
|
+
data.tar.gz: b9acb0eaf2d64128d908ea6ff059bfd662bda4dea654a34487b037efde8595a0c3182cfb368acf3fcaaf02ac27940faa24001c2c1d10a00093f96c7e4f72f229
|
data/lib/warden/jwt/config.rb
CHANGED
@@ -93,6 +93,10 @@ module Warden
|
|
93
93
|
custom_config.fetch(:verify_audience, true)
|
94
94
|
end
|
95
95
|
|
96
|
+
def client_options
|
97
|
+
custom_config.fetch(:client_options, {})
|
98
|
+
end
|
99
|
+
|
96
100
|
def to_hash
|
97
101
|
{ :issuer => issuer,
|
98
102
|
:audience => audience,
|
@@ -100,7 +104,8 @@ module Warden
|
|
100
104
|
:username_param => username_param,
|
101
105
|
:password_param => password_param,
|
102
106
|
:verify_issuer => verify_issuer,
|
103
|
-
:verify_audience => verify_audience
|
107
|
+
:verify_audience => verify_audience,
|
108
|
+
:client_options => client_options }
|
104
109
|
end
|
105
110
|
|
106
111
|
private
|
data/lib/warden/jwt/strategy.rb
CHANGED
@@ -32,14 +32,17 @@ module Warden
|
|
32
32
|
token_url = Addressable::URI.parse(config[:issuer])
|
33
33
|
token_url.path = "/oauth/token"
|
34
34
|
|
35
|
-
response = ::RestClient.
|
36
|
-
token_url.to_s,
|
35
|
+
response = ::RestClient::Request.new(
|
37
36
|
{
|
38
|
-
:
|
39
|
-
:
|
40
|
-
:
|
41
|
-
|
42
|
-
|
37
|
+
:method => :post,
|
38
|
+
:url => token_url.to_s,
|
39
|
+
:payload => {
|
40
|
+
:grant_type => :password,
|
41
|
+
:username => params[config[:username_param]],
|
42
|
+
:password => params[config[:password_param]]
|
43
|
+
}
|
44
|
+
}.merge(config[:client_options])
|
45
|
+
).execute
|
43
46
|
|
44
47
|
yield(response) if block_given?
|
45
48
|
rescue RestClient::Unauthorized
|
data/lib/warden/jwt/version.rb
CHANGED
data/spec/support/vcr.rb
CHANGED
@@ -149,6 +149,22 @@ describe Warden::JWT::Config do
|
|
149
149
|
end
|
150
150
|
end
|
151
151
|
|
152
|
+
describe "#client_options" do
|
153
|
+
context "when specified in config" do
|
154
|
+
let(:client_options) { { :client_options => { :ssl => { :verify => false } } } }
|
155
|
+
it "returns the client_options param" do
|
156
|
+
scope_config[:client_options] = client_options
|
157
|
+
expect(config.client_options).to eq(client_options)
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
context "when not specified" do
|
162
|
+
it "returns nil" do
|
163
|
+
expect(config.client_options).to eq({})
|
164
|
+
end
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
152
168
|
describe "#verify_audience" do
|
153
169
|
context 'when specified in config' do
|
154
170
|
it 'returns the verify_audience param' do
|
@@ -173,11 +189,12 @@ describe Warden::JWT::Config do
|
|
173
189
|
:username_param => 'wef',
|
174
190
|
:password_param => 'wef',
|
175
191
|
:verify_issuer => 'wef',
|
176
|
-
:verify_audience => 'wef'
|
192
|
+
:verify_audience => 'wef',
|
193
|
+
:client_options => 'wef'
|
177
194
|
)
|
178
195
|
|
179
196
|
expect(config.to_hash.keys).
|
180
|
-
to match_array([:issuer, :audience, :secret, :username_param, :password_param, :verify_issuer, :verify_audience])
|
197
|
+
to match_array([:issuer, :audience, :secret, :username_param, :password_param, :verify_issuer, :verify_audience, :client_options])
|
181
198
|
end
|
182
199
|
end
|
183
200
|
end
|
@@ -19,6 +19,7 @@ describe Warden::JWT::Strategy do
|
|
19
19
|
let(:audience) { '1f24bf542b6925ff3b18032f9311c122c21068ce0a09033b207112f826db3d7f' }
|
20
20
|
let(:verify_audience) { false }
|
21
21
|
let(:verify_issuer) { false }
|
22
|
+
let(:client_options) { {} }
|
22
23
|
|
23
24
|
let(:scope_config) do
|
24
25
|
{
|
@@ -26,7 +27,8 @@ describe Warden::JWT::Strategy do
|
|
26
27
|
:audience => audience,
|
27
28
|
:secret => secret,
|
28
29
|
:verify_audience => verify_audience,
|
29
|
-
:verify_issuer => verify_issuer
|
30
|
+
:verify_issuer => verify_issuer,
|
31
|
+
:client_options => client_options
|
30
32
|
}
|
31
33
|
end
|
32
34
|
|
@@ -121,6 +123,17 @@ describe Warden::JWT::Strategy do
|
|
121
123
|
end
|
122
124
|
end
|
123
125
|
|
126
|
+
context "#fetch_token" do
|
127
|
+
context "with client_options set" do
|
128
|
+
let(:client_options) { double('extraconfig') }
|
129
|
+
|
130
|
+
it "passes options through to RestClient" do
|
131
|
+
allow(RestClient).to receive(:post)
|
132
|
+
strategy.fetch_token
|
133
|
+
expect(RestClient).to have_received(:post).with(anything, anything, client_options)
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
124
137
|
|
125
138
|
context "with issuer check" do
|
126
139
|
let(:verify_issuer) { true }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: warden-jwt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rob Sharp
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-07-
|
11
|
+
date: 2015-07-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jwt
|