the_garage 2.6.1 → 2.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 22866c2b96913a0808dc58ee3c6616a1fa190bdd632d5cbcf23ba0781b5012fc
4
- data.tar.gz: c05332be7ec143fe6aec9b52d9e982be382e45db5c1433c67127a69c692add79
3
+ metadata.gz: 80169386da45b2a7fa5b98e3f855e9df7a49e9fac6357cd894bc26eb24d45a95
4
+ data.tar.gz: 0d7dd3a20e97a8aeeebdd79e52b99e8ddf4291b6eba0885b1d7a5cf453265792
5
5
  SHA512:
6
- metadata.gz: 9525bff41a05c514895634c65db08f5644b7c32e2e812f7935df9c7cb68b384d96e21e4bf8ccccc9dbc5561a85d889bd160ff679e9c5e2685a1b07f8c30ed874
7
- data.tar.gz: dd942e114ef1fe840e0a145a3530dbe924970012d66fa7198dacb0409cc1447f36b6111bbb14fdde71ddee5341d76c8a87f4944e8ab3e7a8957ed8513043014a
6
+ metadata.gz: a68873fd908fc82273b263f0234a852bf1537e3c6cce7a0ef957652ec773b711f2b7ee28cb1f183644e8f4bb9421c1c2a60fc5caf1ba567d5cf5e5c630fb00dc
7
+ data.tar.gz: 53ba2171e6f6b1c4eebd3bdc6158e932fea15780a2caecc2b19d5148dfe658c11fb0627cc8bd0c46ba232f29be6d287f9669f3da48a3e595d896df550d8f6aa1
data/README.md CHANGED
@@ -153,7 +153,7 @@ Then configure auth server strategy:
153
153
 
154
154
  The OAuth server must response a json with following structure.
155
155
 
156
- - `token`(string) - OAuth access token value.
156
+ - `token` (string, null) - OAuth access token value.
157
157
  - `token_type` (string) - OAuth access token value. i.e. `bearer` type.
158
158
  - `scope` (string) - OAuth scopes separated by spaces. i.e. `public read_user`.
159
159
  - `application_id` (integer) - OAuth application id of the access token.
@@ -86,7 +86,7 @@ class Garage::Docs::ResourcesController < Garage::ApplicationController
86
86
  def require_console_application
87
87
  @app = console_application
88
88
  if @app[:uid].blank? || @app[:secret].blank?
89
- render(text: 'Configuration for console application is missing.', status: :forbidden)
89
+ render(plain: 'Configuration for console application is missing.', status: :forbidden)
90
90
  end
91
91
  end
92
92
 
@@ -1,7 +1,8 @@
1
1
  module Garage
2
2
  module Strategy
3
3
  class AccessToken
4
- attr_reader :scope, :token, :token_type, :raw_response
4
+ attr_accessor :token
5
+ attr_reader :scope, :token_type, :raw_response
5
6
 
6
7
  def initialize(attrs)
7
8
  @raw_response = attrs
@@ -58,10 +58,8 @@ module Garage
58
58
 
59
59
  def fetch
60
60
  if has_any_valid_credentials?
61
- if has_cacheable_credentials?
62
- fetch_with_cache
63
- else
64
- fetch_without_cache
61
+ fetch_access_token&.tap do |access_token|
62
+ access_token.token ||= token_string
65
63
  end
66
64
  else
67
65
  nil
@@ -144,6 +142,14 @@ module Garage
144
142
  @bearer_token ||= @request.authorization.try {|o| o.slice(/\ABearer\s+(.+)\z/, 1) }
145
143
  end
146
144
 
145
+ def fetch_access_token
146
+ if has_cacheable_credentials?
147
+ fetch_with_cache
148
+ else
149
+ fetch_without_cache
150
+ end
151
+ end
152
+
147
153
  def fetch_with_cache
148
154
  Cache.with_cache("garage_gem/token_cache/#{Garage::VERSION}/#{bearer_token}") do
149
155
  fetch_without_cache
@@ -162,6 +168,12 @@ module Garage
162
168
  end
163
169
  end
164
170
  end
171
+
172
+ def token_string
173
+ bearer_token.presence ||
174
+ @request.params[:access_token].presence ||
175
+ @request.params[:bearer_token].presence
176
+ end
165
177
  end
166
178
 
167
179
  class Response
@@ -1,3 +1,3 @@
1
1
  module Garage
2
- VERSION = '2.6.1'
2
+ VERSION = '2.7.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: the_garage
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.6.1
4
+ version: 2.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tatsuhiko Miyagawa
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-14 00:00:00.000000000 Z
11
+ date: 2021-10-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 4.0.0
19
+ version: 4.2.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 4.0.0
26
+ version: 4.2.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rack-accept-default
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -164,20 +164,6 @@ dependencies:
164
164
  - - ">="
165
165
  - !ruby/object:Gem::Version
166
166
  version: 2.0.0
167
- - !ruby/object:Gem::Dependency
168
- name: appraisal
169
- requirement: !ruby/object:Gem::Requirement
170
- requirements:
171
- - - ">="
172
- - !ruby/object:Gem::Version
173
- version: '0'
174
- type: :development
175
- prerelease: false
176
- version_requirements: !ruby/object:Gem::Requirement
177
- requirements:
178
- - - ">="
179
- - !ruby/object:Gem::Version
180
- version: '0'
181
167
  description: Garage extends your RESTful, Hypermedia APIs as a Platform
182
168
  email:
183
169
  - miyagawa@bulknews.net
@@ -255,7 +241,7 @@ homepage: https://github.com/cookpad/garage
255
241
  licenses:
256
242
  - MIT
257
243
  metadata: {}
258
- post_install_message:
244
+ post_install_message:
259
245
  rdoc_options: []
260
246
  require_paths:
261
247
  - lib
@@ -271,7 +257,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
271
257
  version: '0'
272
258
  requirements: []
273
259
  rubygems_version: 3.1.4
274
- signing_key:
260
+ signing_key:
275
261
  specification_version: 4
276
262
  summary: Garage Platform Engine
277
263
  test_files: []