api_proxy 0.2.7 → 0.2.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -1
- data/.ruby-version +1 -1
- data/Gemfile.lock +102 -61
- data/README.md +2 -0
- data/api_proxy.gemspec +3 -3
- data/lib/api_proxy/config.rb +11 -1
- data/lib/api_proxy/headers_filter.rb +3 -11
- data/lib/api_proxy/response_builder.rb +11 -4
- data/lib/api_proxy/version.rb +1 -1
- metadata +17 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e5eef0dded505216ee8d17ccc306b16854efd171f3971e45901410225810adb5
|
4
|
+
data.tar.gz: 29704f1f5c053fc93247930fbf912a3a6484501b0cedb04862a0b19061044bcf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a74b708a2d35a0d8d078acba1d9b601135e0396164ef695a84e3eb29114790e2f9ac8265c8a3ecc43370241ca6d11207e9454dfd5142f05247e4d43833a68760
|
7
|
+
data.tar.gz: ecc004d5c99b8cae0030ee28c0fa3b70a54d7aebcceef20cd2d489707ee2b1f82bbde82ff98e92f2de0a6f2544003916c08ad07dca518a99fc1509ade5f24ace
|
data/.rubocop.yml
CHANGED
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
3.2.2
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
api_proxy (0.2.
|
4
|
+
api_proxy (0.2.8)
|
5
5
|
activesupport (>= 4.0)
|
6
6
|
api_signature (~> 0.1.2)
|
7
7
|
httparty (>= 0.15)
|
@@ -9,29 +9,66 @@ PATH
|
|
9
9
|
GEM
|
10
10
|
remote: https://rubygems.org/
|
11
11
|
specs:
|
12
|
-
activesupport (7.
|
12
|
+
activesupport (7.1.3.2)
|
13
|
+
base64
|
14
|
+
bigdecimal
|
13
15
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
16
|
+
connection_pool (>= 2.2.5)
|
17
|
+
drb
|
14
18
|
i18n (>= 1.6, < 2)
|
15
19
|
minitest (>= 5.1)
|
20
|
+
mutex_m
|
16
21
|
tzinfo (~> 2.0)
|
17
|
-
addressable (2.8.
|
22
|
+
addressable (2.8.6)
|
18
23
|
public_suffix (>= 2.0.2, < 6.0)
|
19
24
|
api_signature (0.1.5)
|
20
25
|
activesupport (>= 4.0)
|
21
26
|
rack (>= 1.6)
|
22
27
|
ast (2.4.2)
|
28
|
+
base64 (0.2.0)
|
29
|
+
bigdecimal (3.1.7)
|
23
30
|
bundler-audit (0.9.1)
|
24
31
|
bundler (>= 1.2.0, < 3)
|
25
32
|
thor (~> 1.0)
|
26
|
-
childprocess (
|
33
|
+
childprocess (5.0.0)
|
27
34
|
coderay (1.1.3)
|
28
|
-
concurrent-ruby (1.
|
29
|
-
|
35
|
+
concurrent-ruby (1.2.3)
|
36
|
+
connection_pool (2.4.1)
|
37
|
+
crack (1.0.0)
|
38
|
+
bigdecimal
|
30
39
|
rexml
|
31
|
-
diff-lcs (1.5.
|
32
|
-
|
40
|
+
diff-lcs (1.5.1)
|
41
|
+
drb (2.2.1)
|
42
|
+
dry-configurable (1.1.0)
|
43
|
+
dry-core (~> 1.0, < 2)
|
44
|
+
zeitwerk (~> 2.6)
|
45
|
+
dry-core (1.0.1)
|
46
|
+
concurrent-ruby (~> 1.0)
|
47
|
+
zeitwerk (~> 2.6)
|
48
|
+
dry-inflector (1.0.0)
|
49
|
+
dry-initializer (3.1.1)
|
50
|
+
dry-logic (1.5.0)
|
51
|
+
concurrent-ruby (~> 1.0)
|
52
|
+
dry-core (~> 1.0, < 2)
|
53
|
+
zeitwerk (~> 2.6)
|
54
|
+
dry-schema (1.13.3)
|
55
|
+
concurrent-ruby (~> 1.0)
|
56
|
+
dry-configurable (~> 1.0, >= 1.0.1)
|
57
|
+
dry-core (~> 1.0, < 2)
|
58
|
+
dry-initializer (~> 3.0)
|
59
|
+
dry-logic (>= 1.4, < 2)
|
60
|
+
dry-types (>= 1.7, < 2)
|
61
|
+
zeitwerk (~> 2.6)
|
62
|
+
dry-types (1.7.2)
|
63
|
+
bigdecimal (~> 3.0)
|
64
|
+
concurrent-ruby (~> 1.0)
|
65
|
+
dry-core (~> 1.0)
|
66
|
+
dry-inflector (~> 1.0)
|
67
|
+
dry-logic (~> 1.4)
|
68
|
+
zeitwerk (~> 2.6)
|
69
|
+
ffi (1.16.3)
|
33
70
|
formatador (1.1.0)
|
34
|
-
guard (2.18.
|
71
|
+
guard (2.18.1)
|
35
72
|
formatador (>= 0.2.4)
|
36
73
|
listen (>= 2.7, < 4.0)
|
37
74
|
lumberjack (>= 1.0.12, < 2.0)
|
@@ -45,102 +82,106 @@ GEM
|
|
45
82
|
guard (~> 2.1)
|
46
83
|
guard-compat (~> 1.1)
|
47
84
|
rspec (>= 2.99.0, < 4.0)
|
48
|
-
hashdiff (1.0
|
49
|
-
httparty (0.
|
50
|
-
|
85
|
+
hashdiff (1.1.0)
|
86
|
+
httparty (0.21.0)
|
87
|
+
mini_mime (>= 1.0.0)
|
51
88
|
multi_xml (>= 0.5.2)
|
52
|
-
i18n (1.
|
89
|
+
i18n (1.14.4)
|
53
90
|
concurrent-ruby (~> 1.0)
|
54
91
|
iniparse (1.5.0)
|
55
|
-
json (2.
|
56
|
-
|
57
|
-
listen (3.
|
92
|
+
json (2.7.1)
|
93
|
+
language_server-protocol (3.17.0.3)
|
94
|
+
listen (3.9.0)
|
58
95
|
rb-fsevent (~> 0.10, >= 0.10.3)
|
59
96
|
rb-inotify (~> 0.9, >= 0.9.10)
|
60
|
-
lumberjack (1.2.
|
97
|
+
lumberjack (1.2.10)
|
61
98
|
method_source (1.0.0)
|
62
|
-
|
63
|
-
|
64
|
-
mime-types-data (3.2022.0105)
|
65
|
-
minitest (5.16.3)
|
99
|
+
mini_mime (1.1.5)
|
100
|
+
minitest (5.22.3)
|
66
101
|
multi_xml (0.6.0)
|
102
|
+
mutex_m (0.2.0)
|
67
103
|
nenv (0.3.0)
|
68
104
|
notiffany (0.1.3)
|
69
105
|
nenv (~> 0.1)
|
70
106
|
shellany (~> 0.0)
|
71
|
-
overcommit (0.
|
72
|
-
childprocess (>= 0.6.3, <
|
107
|
+
overcommit (0.63.0)
|
108
|
+
childprocess (>= 0.6.3, < 6)
|
73
109
|
iniparse (~> 1.4)
|
74
110
|
rexml (~> 3.2)
|
75
|
-
parallel (1.
|
76
|
-
parser (3.
|
111
|
+
parallel (1.24.0)
|
112
|
+
parser (3.3.0.5)
|
77
113
|
ast (~> 2.4.1)
|
78
|
-
|
114
|
+
racc
|
115
|
+
pry (0.14.2)
|
79
116
|
coderay (~> 1.1)
|
80
117
|
method_source (~> 1.0)
|
81
|
-
public_suffix (5.0.
|
82
|
-
|
118
|
+
public_suffix (5.0.5)
|
119
|
+
racc (1.7.3)
|
120
|
+
rack (3.0.10)
|
83
121
|
rainbow (3.1.1)
|
84
|
-
rake (
|
122
|
+
rake (13.2.0)
|
85
123
|
rb-fsevent (0.11.2)
|
86
124
|
rb-inotify (0.10.1)
|
87
125
|
ffi (~> 1.0)
|
88
|
-
reek (6.
|
89
|
-
|
90
|
-
parser (~> 3.
|
126
|
+
reek (6.3.0)
|
127
|
+
dry-schema (~> 1.13.0)
|
128
|
+
parser (~> 3.3.0)
|
91
129
|
rainbow (>= 2.0, < 4.0)
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
rspec-
|
97
|
-
rspec-
|
98
|
-
|
99
|
-
|
100
|
-
|
130
|
+
rexml (~> 3.1)
|
131
|
+
regexp_parser (2.9.0)
|
132
|
+
rexml (3.2.6)
|
133
|
+
rspec (3.13.0)
|
134
|
+
rspec-core (~> 3.13.0)
|
135
|
+
rspec-expectations (~> 3.13.0)
|
136
|
+
rspec-mocks (~> 3.13.0)
|
137
|
+
rspec-core (3.13.0)
|
138
|
+
rspec-support (~> 3.13.0)
|
139
|
+
rspec-expectations (3.13.0)
|
101
140
|
diff-lcs (>= 1.2.0, < 2.0)
|
102
|
-
rspec-support (~> 3.
|
103
|
-
rspec-mocks (3.
|
141
|
+
rspec-support (~> 3.13.0)
|
142
|
+
rspec-mocks (3.13.0)
|
104
143
|
diff-lcs (>= 1.2.0, < 2.0)
|
105
|
-
rspec-support (~> 3.
|
106
|
-
rspec-support (3.
|
107
|
-
rubocop (1.
|
144
|
+
rspec-support (~> 3.13.0)
|
145
|
+
rspec-support (3.13.1)
|
146
|
+
rubocop (1.62.1)
|
108
147
|
json (~> 2.3)
|
148
|
+
language_server-protocol (>= 3.17.0)
|
109
149
|
parallel (~> 1.10)
|
110
|
-
parser (>= 3.
|
150
|
+
parser (>= 3.3.0.2)
|
111
151
|
rainbow (>= 2.2.2, < 4.0)
|
112
152
|
regexp_parser (>= 1.8, < 3.0)
|
113
153
|
rexml (>= 3.2.5, < 4.0)
|
114
|
-
rubocop-ast (>= 1.
|
154
|
+
rubocop-ast (>= 1.31.1, < 2.0)
|
115
155
|
ruby-progressbar (~> 1.7)
|
116
|
-
unicode-display_width (>=
|
117
|
-
rubocop-ast (1.
|
118
|
-
parser (>= 3.
|
119
|
-
ruby-progressbar (1.
|
156
|
+
unicode-display_width (>= 2.4.0, < 3.0)
|
157
|
+
rubocop-ast (1.31.2)
|
158
|
+
parser (>= 3.3.0.4)
|
159
|
+
ruby-progressbar (1.13.0)
|
120
160
|
shellany (0.0.1)
|
121
|
-
thor (1.
|
122
|
-
tzinfo (2.0.
|
161
|
+
thor (1.3.1)
|
162
|
+
tzinfo (2.0.6)
|
123
163
|
concurrent-ruby (~> 1.0)
|
124
|
-
unicode-display_width (2.
|
125
|
-
webmock (3.
|
164
|
+
unicode-display_width (2.5.0)
|
165
|
+
webmock (3.23.0)
|
126
166
|
addressable (>= 2.8.0)
|
127
167
|
crack (>= 0.3.2)
|
128
168
|
hashdiff (>= 0.4.0, < 2.0.0)
|
169
|
+
zeitwerk (2.6.13)
|
129
170
|
|
130
171
|
PLATFORMS
|
131
|
-
arm64-darwin-
|
172
|
+
arm64-darwin-22
|
132
173
|
|
133
174
|
DEPENDENCIES
|
134
175
|
api_proxy!
|
135
176
|
bundler
|
136
177
|
bundler-audit
|
137
|
-
guard-rspec
|
178
|
+
guard-rspec
|
138
179
|
overcommit
|
139
|
-
rake
|
180
|
+
rake
|
140
181
|
reek
|
141
|
-
rspec
|
182
|
+
rspec
|
142
183
|
rubocop
|
143
184
|
webmock (~> 3.4, >= 3.4.2)
|
144
185
|
|
145
186
|
BUNDLED WITH
|
146
|
-
2.
|
187
|
+
2.4.19
|
data/README.md
CHANGED
data/api_proxy.gemspec
CHANGED
@@ -23,11 +23,11 @@ Gem::Specification.new do |spec|
|
|
23
23
|
|
24
24
|
spec.add_development_dependency 'bundler'
|
25
25
|
spec.add_development_dependency 'bundler-audit'
|
26
|
-
spec.add_development_dependency 'guard-rspec'
|
26
|
+
spec.add_development_dependency 'guard-rspec'
|
27
27
|
spec.add_development_dependency 'overcommit'
|
28
|
-
spec.add_development_dependency 'rake'
|
28
|
+
spec.add_development_dependency 'rake'
|
29
29
|
spec.add_development_dependency 'reek'
|
30
|
-
spec.add_development_dependency 'rspec'
|
30
|
+
spec.add_development_dependency 'rspec'
|
31
31
|
spec.add_development_dependency 'rubocop'
|
32
32
|
spec.add_development_dependency 'webmock', '~> 3.4', '>= 3.4.2'
|
33
33
|
|
data/lib/api_proxy/config.rb
CHANGED
@@ -8,7 +8,8 @@ module ApiProxy
|
|
8
8
|
:request_starts_with,
|
9
9
|
:request_allowed,
|
10
10
|
:custom_headers,
|
11
|
-
:reject_params
|
11
|
+
:reject_params,
|
12
|
+
:allowed_headers
|
12
13
|
|
13
14
|
def initialize
|
14
15
|
load_defaults
|
@@ -28,6 +29,15 @@ module ApiProxy
|
|
28
29
|
@custom_headers = ->(_env) { {} }
|
29
30
|
|
30
31
|
@reject_params = %w[utf8 authenticity_token commit format controller action]
|
32
|
+
|
33
|
+
@allowed_headers = %w[
|
34
|
+
content-type
|
35
|
+
etag
|
36
|
+
cache-control
|
37
|
+
content-length
|
38
|
+
content-disposition
|
39
|
+
content-transfer-encoding
|
40
|
+
]
|
31
41
|
end
|
32
42
|
end
|
33
43
|
end
|
@@ -2,21 +2,13 @@
|
|
2
2
|
|
3
3
|
module ApiProxy
|
4
4
|
class HeadersFilter
|
5
|
-
|
6
|
-
'content-type',
|
7
|
-
'etag',
|
8
|
-
'cache-control',
|
9
|
-
'content-length',
|
10
|
-
'content-disposition',
|
11
|
-
'content-transfer-encoding'
|
12
|
-
].freeze
|
13
|
-
|
14
|
-
def initialize(headers)
|
5
|
+
def initialize(headers, allowed_headers)
|
15
6
|
@headers = headers
|
7
|
+
@allowed_headers = allowed_headers
|
16
8
|
end
|
17
9
|
|
18
10
|
def filter
|
19
|
-
@headers.select { |key, _value|
|
11
|
+
@headers.select { |key, _value| @allowed_headers.include?(key) }
|
20
12
|
.transform_values { |value| Array(value)[0] }
|
21
13
|
end
|
22
14
|
end
|
@@ -20,9 +20,9 @@ module ApiProxy
|
|
20
20
|
|
21
21
|
def response
|
22
22
|
Rack::Response.new(
|
23
|
-
result.to_s,
|
23
|
+
result.body.to_s,
|
24
24
|
result.code,
|
25
|
-
|
25
|
+
response_headers(result)
|
26
26
|
)
|
27
27
|
end
|
28
28
|
|
@@ -42,7 +42,7 @@ module ApiProxy
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def options
|
45
|
-
{ namespace: namespace, body: filtered_params, headers:
|
45
|
+
{ namespace: namespace, body: filtered_params, headers: request_headers }
|
46
46
|
end
|
47
47
|
|
48
48
|
def filtered_params
|
@@ -53,8 +53,15 @@ module ApiProxy
|
|
53
53
|
@params ||= (env['action_dispatch.request.request_parameters'].presence || request.params)
|
54
54
|
end
|
55
55
|
|
56
|
-
def
|
56
|
+
def request_headers
|
57
57
|
config.custom_headers.call(env)
|
58
58
|
end
|
59
|
+
|
60
|
+
def response_headers(response)
|
61
|
+
ApiProxy::HeadersFilter.new(
|
62
|
+
response.headers.merge('content-length' => response.body.size),
|
63
|
+
@config.allowed_headers
|
64
|
+
).filter
|
65
|
+
end
|
59
66
|
end
|
60
67
|
end
|
data/lib/api_proxy/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: api_proxy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Igor Malinovskiy
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-04-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -42,22 +42,16 @@ dependencies:
|
|
42
42
|
name: guard-rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '4.7'
|
48
45
|
- - ">="
|
49
46
|
- !ruby/object:Gem::Version
|
50
|
-
version:
|
47
|
+
version: '0'
|
51
48
|
type: :development
|
52
49
|
prerelease: false
|
53
50
|
version_requirements: !ruby/object:Gem::Requirement
|
54
51
|
requirements:
|
55
|
-
- - "~>"
|
56
|
-
- !ruby/object:Gem::Version
|
57
|
-
version: '4.7'
|
58
52
|
- - ">="
|
59
53
|
- !ruby/object:Gem::Version
|
60
|
-
version:
|
54
|
+
version: '0'
|
61
55
|
- !ruby/object:Gem::Dependency
|
62
56
|
name: overcommit
|
63
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -76,16 +70,16 @@ dependencies:
|
|
76
70
|
name: rake
|
77
71
|
requirement: !ruby/object:Gem::Requirement
|
78
72
|
requirements:
|
79
|
-
- - "
|
73
|
+
- - ">="
|
80
74
|
- !ruby/object:Gem::Version
|
81
|
-
version: '
|
75
|
+
version: '0'
|
82
76
|
type: :development
|
83
77
|
prerelease: false
|
84
78
|
version_requirements: !ruby/object:Gem::Requirement
|
85
79
|
requirements:
|
86
|
-
- - "
|
80
|
+
- - ">="
|
87
81
|
- !ruby/object:Gem::Version
|
88
|
-
version: '
|
82
|
+
version: '0'
|
89
83
|
- !ruby/object:Gem::Dependency
|
90
84
|
name: reek
|
91
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -104,16 +98,16 @@ dependencies:
|
|
104
98
|
name: rspec
|
105
99
|
requirement: !ruby/object:Gem::Requirement
|
106
100
|
requirements:
|
107
|
-
- - "
|
101
|
+
- - ">="
|
108
102
|
- !ruby/object:Gem::Version
|
109
|
-
version: '
|
103
|
+
version: '0'
|
110
104
|
type: :development
|
111
105
|
prerelease: false
|
112
106
|
version_requirements: !ruby/object:Gem::Requirement
|
113
107
|
requirements:
|
114
|
-
- - "
|
108
|
+
- - ">="
|
115
109
|
- !ruby/object:Gem::Version
|
116
|
-
version: '
|
110
|
+
version: '0'
|
117
111
|
- !ruby/object:Gem::Dependency
|
118
112
|
name: rubocop
|
119
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -190,7 +184,7 @@ dependencies:
|
|
190
184
|
- - ">="
|
191
185
|
- !ruby/object:Gem::Version
|
192
186
|
version: '0.15'
|
193
|
-
description:
|
187
|
+
description:
|
194
188
|
email:
|
195
189
|
- igor.malinovskiy@netfixllc.org
|
196
190
|
executables: []
|
@@ -225,7 +219,7 @@ homepage: https://github.com/psyipm/api_proxy
|
|
225
219
|
licenses:
|
226
220
|
- MIT
|
227
221
|
metadata: {}
|
228
|
-
post_install_message:
|
222
|
+
post_install_message:
|
229
223
|
rdoc_options: []
|
230
224
|
require_paths:
|
231
225
|
- lib
|
@@ -240,8 +234,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
240
234
|
- !ruby/object:Gem::Version
|
241
235
|
version: '0'
|
242
236
|
requirements: []
|
243
|
-
rubygems_version: 3.
|
244
|
-
signing_key:
|
237
|
+
rubygems_version: 3.4.10
|
238
|
+
signing_key:
|
245
239
|
specification_version: 4
|
246
240
|
summary: Proxy for tickets service
|
247
241
|
test_files: []
|