the_garage 2.5.0 → 2.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/app/assets/javascripts/garage/docs/console.js.coffee +2 -10
- data/app/controllers/garage/docs/resources_controller.rb +1 -1
- data/lib/garage/docs/engine.rb +1 -1
- data/lib/garage/paginating_responder.rb +1 -1
- data/lib/garage/representer.rb +2 -0
- data/lib/garage/restful_actions.rb +6 -1
- data/lib/garage/strategy/access_token.rb +2 -1
- data/lib/garage/strategy/auth_server.rb +18 -4
- data/lib/garage/version.rb +1 -1
- metadata +6 -21
- data/app/assets/config/manifest.js +0 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: db48e7a0d0aed64278d3ffa5864f19bd70782481411c1414583bd29b0067f006
|
4
|
+
data.tar.gz: e20592e6c499284c41afc51ea27c3c8258d074eae85afc062a20f878945511fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ac22ddabbe44a7c762817f1a361248709348506c06a20f3028460467b5a650bc0fc3db77703f77b586f1783c4854221fc56972f284981c9f44f4571d18cff103
|
7
|
+
data.tar.gz: 37cbe8ea4a2b3cea57eb5ce3ffb199652a35fb973e3e57a77134ca92857d088a8442369f52458d758d46417236ca9e62b19d26fcfdd2b5561b72ba4d6a4e2634
|
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.
|
@@ -9,14 +9,6 @@ jQuery ()->
|
|
9
9
|
$.colorbox.close()
|
10
10
|
ev.preventDefault()
|
11
11
|
|
12
|
-
buildAuthorizedUrl = (base, location, token) ->
|
13
|
-
url = base + location
|
14
|
-
if url.indexOf('?') > 0
|
15
|
-
url += '&'
|
16
|
-
else
|
17
|
-
url += '?'
|
18
|
-
url + 'access_token=' + token
|
19
|
-
|
20
12
|
addNewParamField = (container) ->
|
21
13
|
nextId = "parameter-" + $('.parameter', container).length
|
22
14
|
copy = $('.template .parameter').clone().attr('id', nextId)
|
@@ -52,11 +44,11 @@ jQuery ()->
|
|
52
44
|
$('#api-headers').text ''
|
53
45
|
$('#api-response').text ''
|
54
46
|
|
55
|
-
url = buildAuthorizedUrl $('#base').val(), $('#location').val(), $('#access_token').val()
|
56
47
|
console.log buildData($('.parameters'))
|
57
48
|
$.ajax
|
58
49
|
type: $('#method').val(),
|
59
|
-
url:
|
50
|
+
url: $('#base').val() + $('#location').val(),
|
51
|
+
headers: {'Authorization': 'Bearer ' + $('#access_token').val()},
|
60
52
|
cache: false,
|
61
53
|
data: buildData($('.parameters')),
|
62
54
|
dataType: 'json',
|
@@ -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(
|
89
|
+
render(plain: 'Configuration for console application is missing.', status: :forbidden)
|
90
90
|
end
|
91
91
|
end
|
92
92
|
|
data/lib/garage/docs/engine.rb
CHANGED
data/lib/garage/representer.rb
CHANGED
@@ -228,7 +228,12 @@ module Garage
|
|
228
228
|
end
|
229
229
|
|
230
230
|
def location
|
231
|
-
|
231
|
+
if @resource.try(:respond_to?, :id)
|
232
|
+
hash = { action: :show, id: @resource.id }
|
233
|
+
url_for(hash)
|
234
|
+
hash
|
235
|
+
end
|
236
|
+
rescue ActionController::UrlGenerationError
|
232
237
|
end
|
233
238
|
end
|
234
239
|
end
|
@@ -58,10 +58,8 @@ module Garage
|
|
58
58
|
|
59
59
|
def fetch
|
60
60
|
if has_any_valid_credentials?
|
61
|
-
|
62
|
-
|
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
|
@@ -89,6 +87,8 @@ module Garage
|
|
89
87
|
'Resource-Owner-Id' => @request.headers['Resource-Owner-Id'],
|
90
88
|
'Scopes' => @request.headers['Scopes'],
|
91
89
|
'User-Agent' => USER_AGENT,
|
90
|
+
# ActionDispatch::Request#request_id is only available in Rails 5.0 or later.
|
91
|
+
'X-Request-Id' => @request.uuid,
|
92
92
|
}.reject {|_, v| v.nil? }
|
93
93
|
end
|
94
94
|
|
@@ -142,6 +142,14 @@ module Garage
|
|
142
142
|
@bearer_token ||= @request.authorization.try {|o| o.slice(/\ABearer\s+(.+)\z/, 1) }
|
143
143
|
end
|
144
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
|
+
|
145
153
|
def fetch_with_cache
|
146
154
|
Cache.with_cache("garage_gem/token_cache/#{Garage::VERSION}/#{bearer_token}") do
|
147
155
|
fetch_without_cache
|
@@ -160,6 +168,12 @@ module Garage
|
|
160
168
|
end
|
161
169
|
end
|
162
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
|
163
177
|
end
|
164
178
|
|
165
179
|
class Response
|
data/lib/garage/version.rb
CHANGED
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.
|
4
|
+
version: 2.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tatsuhiko Miyagawa
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-11 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.
|
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.
|
26
|
+
version: 4.2.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rack-accept-default
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -123,7 +123,7 @@ dependencies:
|
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
|
-
name:
|
126
|
+
name: sassc-rails
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
129
|
- - ">="
|
@@ -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
|
@@ -188,7 +174,6 @@ files:
|
|
188
174
|
- MIT-LICENSE
|
189
175
|
- README.md
|
190
176
|
- Rakefile
|
191
|
-
- app/assets/config/manifest.js
|
192
177
|
- app/assets/javascripts/garage/application.js
|
193
178
|
- app/assets/javascripts/garage/docs/console.js.coffee
|
194
179
|
- app/assets/javascripts/garage/docs/jquery.colorbox.js
|
@@ -271,7 +256,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
271
256
|
- !ruby/object:Gem::Version
|
272
257
|
version: '0'
|
273
258
|
requirements: []
|
274
|
-
rubygems_version: 3.1.
|
259
|
+
rubygems_version: 3.1.4
|
275
260
|
signing_key:
|
276
261
|
specification_version: 4
|
277
262
|
summary: Garage Platform Engine
|