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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5850a3c4cdf867ca5cd9b6c0b1f0b264642611db
4
- data.tar.gz: 7e846e427951539fd0e7cd848c29348459e69231
3
+ metadata.gz: 86881b619ac70fde474bbc61fa642f4d80cecbef
4
+ data.tar.gz: bebf0a4300021b9ee6c12b8e60a881e3d32a2782
5
5
  SHA512:
6
- metadata.gz: dc8bd5c392d7c5c88b033a488605a10e46f01889e8641ac010585cc9212dce7014e743ab11c97c3465eecba05c8c62826b9ffebdfd12365879b3ac4fec95ff96
7
- data.tar.gz: 2aaf35c8428bbc5b3cdbc5132f5bf4133dfb8214c030f31d57c43861247d7923220b8ab92af04309ffd6b9adf57616b3337f5d8356b2e48261c0e5635eddb9b9
6
+ metadata.gz: 17b3bd3a9c65b064bb7adc5a06a937343c451316f60ea85b86d5337c4a3b0496a82e84eb9fc5ddd4ff1ee438e2cddf68c1fe165e6b906bbffb3eda75dc5e1eff
7
+ data.tar.gz: b9acb0eaf2d64128d908ea6ff059bfd662bda4dea654a34487b037efde8595a0c3182cfb368acf3fcaaf02ac27940faa24001c2c1d10a00093f96c7e4f72f229
@@ -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
@@ -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.post(
36
- token_url.to_s,
35
+ response = ::RestClient::Request.new(
37
36
  {
38
- :grant_type => :password,
39
- :username => params[config[:username_param]],
40
- :password => params[config[:password_param]]
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
@@ -1,5 +1,5 @@
1
1
  module Warden
2
2
  module JWT
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.1"
4
4
  end
5
5
  end
@@ -4,4 +4,5 @@ VCR.configure do |config|
4
4
  config.cassette_library_dir = "spec/fixtures/vcr_cassettes"
5
5
  config.hook_into :webmock
6
6
  config.configure_rspec_metadata!
7
+ config.ignore_hosts 'codeclimate.com'
7
8
  end
@@ -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.0
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-28 00:00:00.000000000 Z
11
+ date: 2015-07-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jwt