the_garage 2.5.0 → 2.8.0

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: 8a8b827892d32f5517d67991bfc76a4832eba4f3aa5b1c1d1cd1f76141bc3422
4
- data.tar.gz: fce58bbb7be2ef82e68416650419d88e3bf10205c011806660081a594cf29d6a
3
+ metadata.gz: db48e7a0d0aed64278d3ffa5864f19bd70782481411c1414583bd29b0067f006
4
+ data.tar.gz: e20592e6c499284c41afc51ea27c3c8258d074eae85afc062a20f878945511fa
5
5
  SHA512:
6
- metadata.gz: d691e438110eabee1b14a9f011067f67f4cf5119f248843d6c4d8d3f44125e7f7a76f0b56d12cac53770238425c6a2d5f62c4321e8273264ce4306e6f943c0e8
7
- data.tar.gz: d408e49c73f46d1fcda1d3d8f9a61a76b8a7e6411172bf4eace5c38c4572be838e4c0f65e1f8dea5006949532b741fc19de4600d72fccde4a49dc8bc7468f810
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: 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(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,6 +1,6 @@
1
1
  require "rails"
2
2
  require "haml"
3
- require "sass-rails"
3
+ require "sassc-rails"
4
4
  require "coffee-rails"
5
5
  require "redcarpet"
6
6
 
@@ -90,7 +90,7 @@ module Garage
90
90
  links[:next] = rs.current_page + 1
91
91
  end
92
92
 
93
- unless rs.last_page? || hide_total?
93
+ unless rs.last_page? || hide_total? || rs.total_pages.zero?
94
94
  links[:last] = rs.total_pages
95
95
  end
96
96
  end
@@ -1,3 +1,5 @@
1
+ require 'active_support/time_with_zone'
2
+
1
3
  module Garage::Representer
2
4
  attr_accessor :params, :representer_attrs, :partial, :selector
3
5
 
@@ -228,7 +228,12 @@ module Garage
228
228
  end
229
229
 
230
230
  def location
231
- { action: :show, id: @resource.id } if @resource.try(:respond_to?, :id)
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
@@ -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
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Garage
2
- VERSION = '2.5.0'
2
+ VERSION = '2.8.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.5.0
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: 2020-06-25 00:00:00.000000000 Z
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.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
@@ -123,7 +123,7 @@ dependencies:
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
125
  - !ruby/object:Gem::Dependency
126
- name: sass-rails
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.2
259
+ rubygems_version: 3.1.4
275
260
  signing_key:
276
261
  specification_version: 4
277
262
  summary: Garage Platform Engine
@@ -1,2 +0,0 @@
1
- //= link_directory ../javascripts .js
2
- //= link_directory ../stylesheets .css