lhs 26.0.0 → 26.0.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
  SHA256:
3
- metadata.gz: 69eb6dce95fcd8672e27e8a2de0ffadde9f2d43264ea5cdda59b4d9920799c6a
4
- data.tar.gz: ded231b01b80c8d889811425c3cd7a9f3f57867490273d0f7502a66ec8b7c6c9
3
+ metadata.gz: 1e54866cbfede61b6c11e099598cd0a8c742d96d58ab7e428f0cf5510713212a
4
+ data.tar.gz: b4f35820a23216b95316508a2b83d3b90293d575c15f55abd2c8e25807d28451
5
5
  SHA512:
6
- metadata.gz: 68164ed94455f2ed987ea9447597ab4d71a8f7ed3748064250d2972da49a6b0c923ae96e62f22e0bee8da57c9415a2e70bf06eb21ce74bcd5c313a1a4ab496b1
7
- data.tar.gz: b09b62b536b2e89a76a23d41b2570a6a82e939a9cffbf4a84a055df980f4327c186ac366f7d88f8d3c859b703e5fceb948180c42853941dc6e4e4fb21ba413ac
6
+ metadata.gz: a1de279d402f15a73842204180d3810250e911ab399c4d4636fb7672e3512f3f4f6aed25024594fb483b7bcca690964f2e49858157058a231cae231338b46618
7
+ data.tar.gz: 607ca09eafde7d9586e01c4c9e1978b97bfc9b8837fda2eec62ddc3e2ec87dc3700687cb5bd3422c3254204bbd86a08cb4636976600e04dba03af097c99106da
@@ -10,7 +10,7 @@ module LHS
10
10
  class Interceptor < LHC::Interceptor
11
11
 
12
12
  def before_request
13
- request.options[:auth] = { bearer: token }
13
+ request.options[:auth] ||= { bearer: token }
14
14
  end
15
15
 
16
16
  def tokens
data/lib/lhs/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LHS
4
- VERSION = '26.0.0'
4
+ VERSION = '26.0.1'
5
5
  end
@@ -165,5 +165,46 @@ describe 'Auto OAuth Authentication', type: :request, dummy_models: true do
165
165
  expect(records_request).to have_been_requested
166
166
  end
167
167
  end
168
+
169
+ context 'overriding auth options with provider enabled for auto oauth' do
170
+
171
+ let(:token) { ApplicationController::ACCESS_TOKEN }
172
+ let(:overridden_token) { 'ACCESS_TOKEN' }
173
+
174
+ let(:record_request) do
175
+ stub_request(:get, "http://internalservice/v2/records/1")
176
+ .with(
177
+ headers: { 'Authorization' => "Bearer #{overridden_token}" }
178
+ ).to_return(status: 200, body: { name: 'Record' }.to_json)
179
+ end
180
+
181
+ let(:records_request) do
182
+ stub_request(:get, "http://internalservice/v2/records?color=blue")
183
+ .with(
184
+ headers: { 'Authorization' => "Bearer #{overridden_token}" }
185
+ ).to_return(status: 200, body: { items: [{ name: 'Record' }] }.to_json)
186
+ end
187
+
188
+ before do
189
+ LHS.configure do |config|
190
+ config.auto_oauth = -> { access_token }
191
+ end
192
+ LHC.configure do |config|
193
+ config.interceptors = [LHC::Auth]
194
+ end
195
+ record_request
196
+ records_request
197
+ end
198
+
199
+ after do
200
+ LHC.config.reset
201
+ end
202
+
203
+ it 'applies OAuth credentials for the individual request automatically' do
204
+ get '/automatic_authentication/oauth_with_provider_override', params: { access_token: overridden_token }
205
+ expect(record_request).to have_been_requested
206
+ expect(records_request).to have_been_requested
207
+ end
208
+ end
168
209
  end
169
210
  end
@@ -26,4 +26,11 @@ class AutomaticAuthenticationController < ApplicationController
26
26
  records: DummyRecordWithAutoOauthProvider.where(color: 'blue').as_json
27
27
  }
28
28
  end
29
+
30
+ def o_auth_with_provider_override
31
+ render json: {
32
+ record: DummyRecordWithAutoOauthProvider.options(auth: { bearer: params[:access_token] }).find(1).as_json,
33
+ records: DummyRecordWithAutoOauthProvider.options(auth: { bearer: params[:access_token] }).where(color: 'blue').as_json
34
+ }
35
+ end
29
36
  end
@@ -7,6 +7,7 @@ Rails.application.routes.draw do
7
7
  get 'automatic_authentication/oauth' => 'automatic_authentication#o_auth'
8
8
  get 'automatic_authentication/oauth_with_multiple_providers' => 'automatic_authentication#o_auth_with_multiple_providers'
9
9
  get 'automatic_authentication/oauth_with_provider' => 'automatic_authentication#o_auth_with_provider'
10
+ get 'automatic_authentication/oauth_with_provider_override' => 'automatic_authentication#o_auth_with_provider_override'
10
11
 
11
12
  # Request Cycle Cache
12
13
  get 'request_cycle_cache/simple' => 'request_cycle_cache#simple'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lhs
3
3
  version: !ruby/object:Gem::Version
4
- version: 26.0.0
4
+ version: 26.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - https://github.com/local-ch/lhs/graphs/contributors
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-05-12 00:00:00.000000000 Z
11
+ date: 2021-09-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -564,7 +564,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
564
564
  version: '0'
565
565
  requirements:
566
566
  - Ruby >= 2.3.0
567
- rubygems_version: 3.0.8
567
+ rubygems_version: 3.1.4
568
568
  signing_key:
569
569
  specification_version: 4
570
570
  summary: 'REST services accelerator: Rails gem providing an easy, active-record-like