apisonator 2.100.2.pre1 → 3.0.0.pre1
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 +4 -4
- data/CHANGELOG.md +40 -0
- data/Gemfile.base +0 -1
- data/Gemfile.lock +7 -21
- data/Gemfile.on_prem.lock +7 -21
- data/lib/3scale/backend.rb +0 -1
- data/lib/3scale/backend/application.rb +22 -6
- data/lib/3scale/backend/configuration.rb +2 -3
- data/lib/3scale/backend/errors.rb +0 -36
- data/lib/3scale/backend/listener.rb +2 -83
- data/lib/3scale/backend/metric/collection.rb +1 -4
- data/lib/3scale/backend/storage_async/client.rb +3 -1
- data/lib/3scale/backend/storage_helpers.rb +7 -2
- data/lib/3scale/backend/transactor.rb +27 -14
- data/lib/3scale/backend/transactor/report_job.rb +1 -1
- data/lib/3scale/backend/transactor/status.rb +0 -5
- data/lib/3scale/backend/usage_limit.rb +20 -11
- data/lib/3scale/backend/version.rb +1 -1
- data/licenses.xml +6 -66
- metadata +2 -9
- data/lib/3scale/backend/oauth.rb +0 -4
- data/lib/3scale/backend/oauth/token.rb +0 -26
- data/lib/3scale/backend/oauth/token_key.rb +0 -30
- data/lib/3scale/backend/oauth/token_storage.rb +0 -313
- data/lib/3scale/backend/oauth/token_value.rb +0 -25
- data/lib/3scale/backend/views/oauth_access_tokens.builder +0 -14
- data/lib/3scale/backend/views/oauth_app_id_by_token.builder +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0fa79b460b2906815bfb027b35522ea438f4ecb8952643c2c66b886a28dcff09
|
4
|
+
data.tar.gz: 491656a6738201be52b2d3062b916db4f52cb38dd3edc8a2ba2b0c5816412a73
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 75f2a8668f08c65ea4b125c1a1c86939f1e75e7d8b0d0aa5c2c084881fbe380a7eed3a8863d391f029d78460fd5f3c8036ec8c208177dd1fda813808577ed351
|
7
|
+
data.tar.gz: eb6f93ad8861cb4916afa819a8d2bc35db94b6c240c34048dd5e6ec5039ae7ade2977b3d0c251b86a63e710a73f1918785ecfd12f195f6e1dfb4d7bf12004fb4
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,46 @@
|
|
2
2
|
|
3
3
|
Notable changes to Apisonator will be tracked in this document.
|
4
4
|
|
5
|
+
## 2.101.1 - 2020-06-05
|
6
|
+
|
7
|
+
### Fixed
|
8
|
+
|
9
|
+
- Fixed a bug introduced in the previous version that made apisonator return an
|
10
|
+
error when authorizing some requests with the `no_body` option enabled
|
11
|
+
([#224](https://github.com/3scale/apisonator/pull/224)).
|
12
|
+
|
13
|
+
|
14
|
+
## 2.101.0 - 2020-06-04
|
15
|
+
|
16
|
+
### Added
|
17
|
+
|
18
|
+
- Introduced the `CONFIG_REDIS_MAX_CONNS` and `CONFIG_QUEUES_MAX_CONNS` ENVs to
|
19
|
+
configure the max number of Redis connections when using the async mode
|
20
|
+
([#214](https://github.com/3scale/apisonator/pull/214)).
|
21
|
+
|
22
|
+
### Changed
|
23
|
+
|
24
|
+
- Perf optimization: loading the usage limits is now done more efficiently.
|
25
|
+
There is a noticeable improvement in requests with `no_body` enabled for
|
26
|
+
services with many metrics defined
|
27
|
+
([#221](https://github.com/3scale/apisonator/pull/221)).
|
28
|
+
- Updated activesupport to 5.2.4.3
|
29
|
+
([#217](https://github.com/3scale/apisonator/pull/217)).
|
30
|
+
|
31
|
+
|
32
|
+
## 2.100.2 - 2020-05-08
|
33
|
+
|
34
|
+
### Changed
|
35
|
+
|
36
|
+
- The Prometheus histogram buckets of the workers have been adjusted to be more
|
37
|
+
informative ([#208](https://github.com/3scale/apisonator/pull/208)).
|
38
|
+
|
39
|
+
### Removed
|
40
|
+
|
41
|
+
- The deprecated endpoints to create, delete, and list oauth tokens have been
|
42
|
+
disabled ([#212](https://github.com/3scale/apisonator/pull/212)).
|
43
|
+
|
44
|
+
|
5
45
|
## 2.100.1 - 2020-04-22
|
6
46
|
|
7
47
|
### Changed
|
data/Gemfile.base
CHANGED
data/Gemfile.lock
CHANGED
@@ -35,14 +35,14 @@ GIT
|
|
35
35
|
PATH
|
36
36
|
remote: .
|
37
37
|
specs:
|
38
|
-
apisonator (
|
38
|
+
apisonator (3.0.0.pre1)
|
39
39
|
|
40
40
|
GEM
|
41
41
|
remote: https://rubygems.org/
|
42
42
|
specs:
|
43
|
-
activesupport (5.
|
43
|
+
activesupport (5.2.4.3)
|
44
44
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
45
|
-
i18n (
|
45
|
+
i18n (>= 0.7, < 2)
|
46
46
|
minitest (~> 5.1)
|
47
47
|
tzinfo (~> 1.1)
|
48
48
|
airbrake (4.3.1)
|
@@ -95,7 +95,7 @@ GEM
|
|
95
95
|
codeclimate-test-reporter (0.6.0)
|
96
96
|
simplecov (>= 0.7.1, < 1.0.0)
|
97
97
|
coderay (1.1.2)
|
98
|
-
concurrent-ruby (1.
|
98
|
+
concurrent-ruby (1.1.6)
|
99
99
|
console (1.8.2)
|
100
100
|
daemons (1.2.4)
|
101
101
|
diff-lcs (1.3)
|
@@ -112,20 +112,10 @@ GEM
|
|
112
112
|
process-metrics (~> 0.1.0)
|
113
113
|
rack (>= 1.0)
|
114
114
|
samovar (~> 2.1)
|
115
|
-
faraday (0.13.1)
|
116
|
-
multipart-post (>= 1.2, < 3)
|
117
115
|
ffi (1.12.2)
|
118
|
-
geminabox (0.13.11)
|
119
|
-
builder
|
120
|
-
faraday
|
121
|
-
httpclient (>= 2.2.7)
|
122
|
-
nesty
|
123
|
-
reentrant_flock
|
124
|
-
sinatra (>= 1.2.7)
|
125
116
|
gli (2.16.1)
|
126
117
|
hiredis (0.6.3)
|
127
|
-
|
128
|
-
i18n (0.9.1)
|
118
|
+
i18n (1.8.2)
|
129
119
|
concurrent-ruby (~> 1.0)
|
130
120
|
jmespath (1.3.1)
|
131
121
|
json (2.1.0)
|
@@ -141,15 +131,13 @@ GEM
|
|
141
131
|
metaclass (0.0.4)
|
142
132
|
method_source (0.9.0)
|
143
133
|
mini_portile2 (2.4.0)
|
144
|
-
minitest (5.
|
134
|
+
minitest (5.14.1)
|
145
135
|
mocha (1.3.0)
|
146
136
|
metaclass (~> 0.0.1)
|
147
137
|
mono_logger (1.1.0)
|
148
138
|
multi_json (1.13.1)
|
149
|
-
multipart-post (2.0.0)
|
150
139
|
mustache (1.0.5)
|
151
140
|
mustermann (1.0.2)
|
152
|
-
nesty (1.0.2)
|
153
141
|
net-scp (1.2.1)
|
154
142
|
net-ssh (>= 2.6.5)
|
155
143
|
net-ssh (4.2.0)
|
@@ -191,7 +179,6 @@ GEM
|
|
191
179
|
rake (13.0.1)
|
192
180
|
redis-namespace (1.6.0)
|
193
181
|
redis (>= 3.0.4)
|
194
|
-
reentrant_flock (0.1.1)
|
195
182
|
resque_spec (0.17.0)
|
196
183
|
resque (>= 1.19.0)
|
197
184
|
rspec-core (>= 3.0.0)
|
@@ -256,7 +243,7 @@ GEM
|
|
256
243
|
timers (4.3.0)
|
257
244
|
toml (0.2.0)
|
258
245
|
parslet (~> 1.8.0)
|
259
|
-
tzinfo (1.2.
|
246
|
+
tzinfo (1.2.7)
|
260
247
|
thread_safe (~> 0.1)
|
261
248
|
vegas (0.1.11)
|
262
249
|
rack (>= 1.0.0)
|
@@ -288,7 +275,6 @@ DEPENDENCIES
|
|
288
275
|
codeclimate-test-reporter (~> 0.6.0)
|
289
276
|
daemons (= 1.2.4)
|
290
277
|
falcon (~> 0.35)
|
291
|
-
geminabox (~> 0.13.11)
|
292
278
|
gli (~> 2.16.1)
|
293
279
|
hiredis (~> 0.6.1)
|
294
280
|
license_finder (~> 5)
|
data/Gemfile.on_prem.lock
CHANGED
@@ -35,14 +35,14 @@ GIT
|
|
35
35
|
PATH
|
36
36
|
remote: .
|
37
37
|
specs:
|
38
|
-
apisonator (
|
38
|
+
apisonator (3.0.0.pre1)
|
39
39
|
|
40
40
|
GEM
|
41
41
|
remote: https://rubygems.org/
|
42
42
|
specs:
|
43
|
-
activesupport (5.
|
43
|
+
activesupport (5.2.4.3)
|
44
44
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
45
|
-
i18n (
|
45
|
+
i18n (>= 0.7, < 2)
|
46
46
|
minitest (~> 5.1)
|
47
47
|
tzinfo (~> 1.1)
|
48
48
|
async (1.24.2)
|
@@ -85,7 +85,7 @@ GEM
|
|
85
85
|
codeclimate-test-reporter (0.6.0)
|
86
86
|
simplecov (>= 0.7.1, < 1.0.0)
|
87
87
|
coderay (1.1.2)
|
88
|
-
concurrent-ruby (1.
|
88
|
+
concurrent-ruby (1.1.6)
|
89
89
|
console (1.8.2)
|
90
90
|
daemons (1.2.4)
|
91
91
|
diff-lcs (1.3)
|
@@ -102,20 +102,10 @@ GEM
|
|
102
102
|
process-metrics (~> 0.1.0)
|
103
103
|
rack (>= 1.0)
|
104
104
|
samovar (~> 2.1)
|
105
|
-
faraday (0.13.1)
|
106
|
-
multipart-post (>= 1.2, < 3)
|
107
105
|
ffi (1.12.2)
|
108
|
-
geminabox (0.13.11)
|
109
|
-
builder
|
110
|
-
faraday
|
111
|
-
httpclient (>= 2.2.7)
|
112
|
-
nesty
|
113
|
-
reentrant_flock
|
114
|
-
sinatra (>= 1.2.7)
|
115
106
|
gli (2.16.1)
|
116
107
|
hiredis (0.6.3)
|
117
|
-
|
118
|
-
i18n (0.9.1)
|
108
|
+
i18n (1.8.2)
|
119
109
|
concurrent-ruby (~> 1.0)
|
120
110
|
json (2.1.0)
|
121
111
|
license_finder (5.9.2)
|
@@ -130,15 +120,13 @@ GEM
|
|
130
120
|
metaclass (0.0.4)
|
131
121
|
method_source (0.9.0)
|
132
122
|
mini_portile2 (2.4.0)
|
133
|
-
minitest (5.
|
123
|
+
minitest (5.14.1)
|
134
124
|
mocha (1.3.0)
|
135
125
|
metaclass (~> 0.0.1)
|
136
126
|
mono_logger (1.1.0)
|
137
127
|
multi_json (1.13.1)
|
138
|
-
multipart-post (2.0.0)
|
139
128
|
mustache (1.0.5)
|
140
129
|
mustermann (1.0.2)
|
141
|
-
nesty (1.0.2)
|
142
130
|
net-scp (1.2.1)
|
143
131
|
net-ssh (>= 2.6.5)
|
144
132
|
net-ssh (4.2.0)
|
@@ -179,7 +167,6 @@ GEM
|
|
179
167
|
rake (13.0.1)
|
180
168
|
redis-namespace (1.6.0)
|
181
169
|
redis (>= 3.0.4)
|
182
|
-
reentrant_flock (0.1.1)
|
183
170
|
resque_spec (0.17.0)
|
184
171
|
resque (>= 1.19.0)
|
185
172
|
rspec-core (>= 3.0.0)
|
@@ -242,7 +229,7 @@ GEM
|
|
242
229
|
timers (4.3.0)
|
243
230
|
toml (0.2.0)
|
244
231
|
parslet (~> 1.8.0)
|
245
|
-
tzinfo (1.2.
|
232
|
+
tzinfo (1.2.7)
|
246
233
|
thread_safe (~> 0.1)
|
247
234
|
vegas (0.1.11)
|
248
235
|
rack (>= 1.0.0)
|
@@ -270,7 +257,6 @@ DEPENDENCIES
|
|
270
257
|
codeclimate-test-reporter (~> 0.6.0)
|
271
258
|
daemons (= 1.2.4)
|
272
259
|
falcon (~> 0.35)
|
273
|
-
geminabox (~> 0.13.11)
|
274
260
|
gli (~> 2.16.1)
|
275
261
|
hiredis (~> 0.6.1)
|
276
262
|
license_finder (~> 5)
|
data/lib/3scale/backend.rb
CHANGED
@@ -35,7 +35,6 @@ require '3scale/backend/rack'
|
|
35
35
|
require '3scale/backend/extensions'
|
36
36
|
require '3scale/backend/background_job'
|
37
37
|
require '3scale/backend/storage'
|
38
|
-
require '3scale/backend/oauth'
|
39
38
|
require '3scale/backend/memoizer'
|
40
39
|
require '3scale/backend/application'
|
41
40
|
require '3scale/backend/error_storage'
|
@@ -91,8 +91,8 @@ module ThreeScale
|
|
91
91
|
end
|
92
92
|
end
|
93
93
|
|
94
|
-
def extract_id!(service_id, app_id, user_key
|
95
|
-
with_app_id_from_params service_id, app_id, user_key
|
94
|
+
def extract_id!(service_id, app_id, user_key)
|
95
|
+
with_app_id_from_params service_id, app_id, user_key do |appid|
|
96
96
|
exists? service_id, appid and appid
|
97
97
|
end
|
98
98
|
end
|
@@ -106,7 +106,6 @@ module ThreeScale
|
|
106
106
|
raise ApplicationNotFound, id unless exists?(service_id, id)
|
107
107
|
delete_data service_id, id
|
108
108
|
clear_cache service_id, id
|
109
|
-
OAuth::Token::Storage.remove_tokens(service_id, id)
|
110
109
|
end
|
111
110
|
|
112
111
|
def delete_data(service_id, id)
|
@@ -157,14 +156,12 @@ module ThreeScale
|
|
157
156
|
)
|
158
157
|
end
|
159
158
|
|
160
|
-
def with_app_id_from_params(service_id, app_id, user_key
|
159
|
+
def with_app_id_from_params(service_id, app_id, user_key)
|
161
160
|
if app_id
|
162
161
|
raise AuthenticationError unless user_key.nil?
|
163
162
|
elsif user_key
|
164
163
|
app_id = load_id_by_key(service_id, user_key)
|
165
164
|
raise UserKeyInvalid, user_key if app_id.nil?
|
166
|
-
elsif access_token
|
167
|
-
app_id, * = OAuth::Token::Storage.get_credentials access_token, service_id
|
168
165
|
else
|
169
166
|
raise ApplicationNotFound
|
170
167
|
end
|
@@ -223,6 +220,25 @@ module ThreeScale
|
|
223
220
|
@usage_limits ||= UsageLimit.load_all(service_id, plan_id)
|
224
221
|
end
|
225
222
|
|
223
|
+
def load_all_usage_limits
|
224
|
+
@usage_limits = UsageLimit.load_all(service_id, plan_id)
|
225
|
+
end
|
226
|
+
|
227
|
+
# Loads the usage limits affected by the metrics received, that is, the
|
228
|
+
# limits that are defined for those metrics plus all their ancestors in
|
229
|
+
# the metrics hierarchy.
|
230
|
+
# Raises MetricInvalid when a metric does not exist.
|
231
|
+
def load_usage_limits_affected_by(metric_names)
|
232
|
+
metric_ids = metric_names.flat_map do |name|
|
233
|
+
[name] + Metric.ascendants(service_id, name)
|
234
|
+
end.uniq.map do |name|
|
235
|
+
Metric.load_id(service_id, name) || raise(MetricInvalid.new(name))
|
236
|
+
end
|
237
|
+
|
238
|
+
# IDs are sorted to be able to use the memoizer
|
239
|
+
@usage_limits = UsageLimit.load_for_affecting_metrics(service_id, plan_id, metric_ids.sort)
|
240
|
+
end
|
241
|
+
|
226
242
|
def active?
|
227
243
|
state == :active
|
228
244
|
end
|
@@ -46,9 +46,9 @@ module ThreeScale
|
|
46
46
|
|
47
47
|
# Add configuration sections
|
48
48
|
config.add_section(:queues, :master_name, :sentinels, :role,
|
49
|
-
:connect_timeout, :read_timeout, :write_timeout)
|
49
|
+
:connect_timeout, :read_timeout, :write_timeout, :max_connections)
|
50
50
|
config.add_section(:redis, :url, :proxy, :sentinels, :role,
|
51
|
-
:connect_timeout, :read_timeout, :write_timeout,
|
51
|
+
:connect_timeout, :read_timeout, :write_timeout, :max_connections,
|
52
52
|
:async)
|
53
53
|
config.add_section(:analytics_redis, :server,
|
54
54
|
:connect_timeout, :read_timeout, :write_timeout)
|
@@ -57,7 +57,6 @@ module ThreeScale
|
|
57
57
|
config.add_section(:redshift, :host, :port, :dbname, :user, :password)
|
58
58
|
config.add_section(:statsd, :host, :port)
|
59
59
|
config.add_section(:internal_api, :user, :password)
|
60
|
-
config.add_section(:oauth, :max_token_size)
|
61
60
|
config.add_section(:master, :metrics)
|
62
61
|
config.add_section(:worker_prometheus_metrics, :enabled, :port)
|
63
62
|
config.add_section(:listener_prometheus_metrics, :enabled, :port)
|
@@ -73,36 +73,6 @@ module ThreeScale
|
|
73
73
|
end
|
74
74
|
end
|
75
75
|
|
76
|
-
class AccessTokenInvalid < NotFound
|
77
|
-
def initialize(id = nil)
|
78
|
-
super %(token "#{id}" is invalid: expired or never defined)
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
class AccessTokenAlreadyExists < Error
|
83
|
-
def initialize(id = nil)
|
84
|
-
super %(token "#{id}" already exists)
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
class AccessTokenStorageError < Error
|
89
|
-
def initialize(id = nil)
|
90
|
-
super %(storage error when saving token "#{id}")
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
class AccessTokenFormatInvalid < Invalid
|
95
|
-
def initialize
|
96
|
-
super 'token is either too big or has an invalid format'.freeze
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
class AccessTokenInvalidTTL < Invalid
|
101
|
-
def initialize
|
102
|
-
super 'the specified TTL should be a positive integer'.freeze
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
76
|
class ServiceNotActive < Error
|
107
77
|
def initialize
|
108
78
|
super 'service is not active'.freeze
|
@@ -182,12 +152,6 @@ module ThreeScale
|
|
182
152
|
end
|
183
153
|
end
|
184
154
|
|
185
|
-
class RequiredParamsMissing < Invalid
|
186
|
-
def initialize
|
187
|
-
super 'missing required parameters'.freeze
|
188
|
-
end
|
189
|
-
end
|
190
|
-
|
191
155
|
class UsageValueInvalid < Error
|
192
156
|
def initialize(metric_name, value)
|
193
157
|
if !value.is_a?(String) || value.blank?
|
@@ -30,9 +30,6 @@ module ThreeScale
|
|
30
30
|
##~ @parameter_app_id_inline = @parameter_app_id.clone
|
31
31
|
##~ @parameter_app_id_inline["description_inline"] = true
|
32
32
|
##
|
33
|
-
##~ @parameter_access_token = {"name" => "access_token", "dataType" => "string", "required" => false, "paramType" => "query", "threescale_name" => "access_tokens"}
|
34
|
-
##~ @parameter_access_token["description"] = "OAuth token used for authorizing if you don't use client_id with client_secret."
|
35
|
-
##
|
36
33
|
##~ @parameter_client_id = {"name" => "app_id", "dataType" => "string", "required" => false, "paramType" => "query", "threescale_name" => "app_ids"}
|
37
34
|
##~ @parameter_client_id["description"] = "Client Id (identifier of the application if the auth. pattern is OAuth, note that client_id == app_id)"
|
38
35
|
##~ @parameter_client_id_inline = @parameter_client_id.clone
|
@@ -114,8 +111,7 @@ module ThreeScale
|
|
114
111
|
|
115
112
|
|
116
113
|
AUTH_AUTHREP_COMMON_PARAMS = ['service_id'.freeze, 'app_id'.freeze, 'app_key'.freeze,
|
117
|
-
'user_key'.freeze, 'provider_key'.freeze
|
118
|
-
'access_token'.freeze].freeze
|
114
|
+
'user_key'.freeze, 'provider_key'.freeze].freeze
|
119
115
|
private_constant :AUTH_AUTHREP_COMMON_PARAMS
|
120
116
|
|
121
117
|
REPORT_EXPECTED_PARAMS = ['provider_key'.freeze,
|
@@ -128,8 +124,6 @@ module ThreeScale
|
|
128
124
|
disable :dump_errors
|
129
125
|
end
|
130
126
|
|
131
|
-
set :views, File.dirname(__FILE__) + '/views'
|
132
|
-
|
133
127
|
use Backend::Rack::ExceptionCatcher
|
134
128
|
|
135
129
|
before do
|
@@ -252,7 +246,7 @@ module ThreeScale
|
|
252
246
|
##~ op.summary = "Authorize (OAuth authentication mode pattern)"
|
253
247
|
##
|
254
248
|
##~ op.description = "<p>Read-only operation to authorize an application in the OAuth authentication pattern."
|
255
|
-
##~ @oauth_security = "<p>When using this endpoint please pay attention at your handling of app_id and app_key parameters. If you don't specify an app_key, the endpoint assumes the app_id specified has already been authenticated by other means. If you specify the app_key parameter, even if it is empty, it will be checked against the application's keys. If you don't trust the app_id value you have,
|
249
|
+
##~ @oauth_security = "<p>When using this endpoint please pay attention at your handling of app_id and app_key parameters. If you don't specify an app_key, the endpoint assumes the app_id specified has already been authenticated by other means. If you specify the app_key parameter, even if it is empty, it will be checked against the application's keys. If you don't trust the app_id value you have, use app keys and specify one."
|
256
250
|
##~ @oauth_desc_response = "<p>This call returns extra data (secret and redirect_url) needed to power OAuth APIs. It's only available for users with OAuth enabled APIs."
|
257
251
|
##~ op.description = op.description + @oauth_security + @oauth_desc_response
|
258
252
|
##~ op.description = op.description + " " + @authorize_desc + " " + @authorize_desc_response
|
@@ -263,7 +257,6 @@ module ThreeScale
|
|
263
257
|
##
|
264
258
|
##~ op.parameters.add @parameter_service_token
|
265
259
|
##~ op.parameters.add @parameter_service_id
|
266
|
-
##~ op.parameters.add @parameter_access_token
|
267
260
|
##~ op.parameters.add @parameter_client_id
|
268
261
|
##~ op.parameters.add @parameter_app_key_oauth
|
269
262
|
##~ op.parameters.add @parameter_referrer
|
@@ -337,7 +330,6 @@ module ThreeScale
|
|
337
330
|
##
|
338
331
|
##~ op.parameters.add @parameter_service_token
|
339
332
|
##~ op.parameters.add @parameter_service_id
|
340
|
-
##~ op.parameters.add @parameter_access_token
|
341
333
|
##~ op.parameters.add @parameter_client_id
|
342
334
|
##~ op.parameters.add @parameter_app_key_oauth
|
343
335
|
##~ op.parameters.add @parameter_referrer
|
@@ -430,62 +422,6 @@ module ThreeScale
|
|
430
422
|
202
|
431
423
|
end
|
432
424
|
|
433
|
-
## OAUTH ACCESS TOKENS
|
434
|
-
|
435
|
-
# These endpoints are deprecated and are going to be removed. For now,
|
436
|
-
# let's disable them.
|
437
|
-
if Backend.test?
|
438
|
-
post '/services/:service_id/oauth_access_tokens.xml' do
|
439
|
-
check_post_content_type!
|
440
|
-
require_params! :service_id, :token
|
441
|
-
|
442
|
-
service_id = params[:service_id]
|
443
|
-
ensure_authenticated!(params[:provider_key], params[:service_token], service_id)
|
444
|
-
|
445
|
-
app_id = params[:app_id]
|
446
|
-
raise ApplicationNotFound, app_id unless Application.exists?(service_id, app_id)
|
447
|
-
|
448
|
-
OAuth::Token::Storage.create(params[:token], service_id, app_id, params[:ttl])
|
449
|
-
end
|
450
|
-
|
451
|
-
delete '/services/:service_id/oauth_access_tokens/:token.xml' do
|
452
|
-
require_params! :service_id, :token
|
453
|
-
|
454
|
-
service_id = params[:service_id]
|
455
|
-
ensure_authenticated!(params[:provider_key], params[:service_token], service_id)
|
456
|
-
|
457
|
-
token = params[:token]
|
458
|
-
|
459
|
-
# TODO: perhaps improve this to list the deleted tokens?
|
460
|
-
raise AccessTokenInvalid, token unless OAuth::Token::Storage.delete(token, service_id)
|
461
|
-
end
|
462
|
-
|
463
|
-
get '/services/:service_id/applications/:app_id/oauth_access_tokens.xml' do
|
464
|
-
require_params! :service_id, :app_id
|
465
|
-
|
466
|
-
service_id = params[:service_id]
|
467
|
-
ensure_authenticated!(params[:provider_key], params[:service_token], service_id)
|
468
|
-
|
469
|
-
app_id = params[:app_id]
|
470
|
-
|
471
|
-
raise ApplicationNotFound, app_id unless Application.exists?(service_id, app_id)
|
472
|
-
|
473
|
-
@tokens = OAuth::Token::Storage.all_by_service_and_app service_id, app_id
|
474
|
-
builder :oauth_access_tokens
|
475
|
-
end
|
476
|
-
|
477
|
-
get '/services/:service_id/oauth_access_tokens/:token.xml' do
|
478
|
-
require_params! :service_id, :token
|
479
|
-
|
480
|
-
service_id = params[:service_id]
|
481
|
-
ensure_authenticated!(params[:provider_key], params[:service_token], service_id)
|
482
|
-
|
483
|
-
@token_to_app_id = OAuth::Token::Storage.get_credentials(params[:token], service_id)
|
484
|
-
|
485
|
-
builder :oauth_app_id_by_token
|
486
|
-
end
|
487
|
-
end
|
488
|
-
|
489
425
|
get '/check.txt' do
|
490
426
|
content_type 'text/plain'
|
491
427
|
body 'ok'
|
@@ -518,10 +454,6 @@ module ThreeScale
|
|
518
454
|
params[:usage].nil? || params[:usage].is_a?(Hash)
|
519
455
|
end
|
520
456
|
|
521
|
-
def require_params!(*keys)
|
522
|
-
raise RequiredParamsMissing unless params && keys.all? { |key| !blank?(params[key]) }
|
523
|
-
end
|
524
|
-
|
525
457
|
def check_params_value_encoding!(input_params, params_to_validate)
|
526
458
|
params_to_validate.each do |p|
|
527
459
|
param_value = input_params[p]
|
@@ -604,10 +536,6 @@ module ThreeScale
|
|
604
536
|
end
|
605
537
|
end
|
606
538
|
|
607
|
-
def application
|
608
|
-
@application ||= Application.load_by_id_or_user_key!(service_id, params[:app_id], params[:user_key])
|
609
|
-
end
|
610
|
-
|
611
539
|
def service_id
|
612
540
|
if params[:service_id].nil? || params[:service_id].empty?
|
613
541
|
@service_id ||= Service.default_id!(params[:provider_key])
|
@@ -655,15 +583,6 @@ module ThreeScale
|
|
655
583
|
raise ServiceTokenInvalid.new(token, id)
|
656
584
|
end
|
657
585
|
|
658
|
-
def ensure_authenticated!(provider_key, service_token, service_id)
|
659
|
-
if blank?(provider_key)
|
660
|
-
key = provider_key_from(service_token, service_id)
|
661
|
-
raise_provider_key_error(params) if blank?(key)
|
662
|
-
elsif !Service.authenticate_service_id(service_id, provider_key)
|
663
|
-
raise ProviderKeyInvalid, provider_key
|
664
|
-
end
|
665
|
-
end
|
666
|
-
|
667
586
|
def response_auth_call(auth_status)
|
668
587
|
status(auth_status.authorized? ? 200 : 409)
|
669
588
|
optionally_set_headers(auth_status)
|