setsuzoku 0.12.58 → 0.14.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +20 -17
- data/lib/setsuzoku/service/web_service/api_strategies/rest_strategy.rb +2 -2
- data/lib/setsuzoku/service/web_service/api_strategy.rb +10 -0
- data/lib/setsuzoku/service/web_service/auth_strategies/strategy_can_use_tokens.rb +15 -25
- data/lib/setsuzoku/service/web_service/credentials/o_auth_credential.rb +0 -20
- data/lib/setsuzoku/service/web_service/credentials/uses_credential_token.rb +5 -5
- data/lib/setsuzoku/version.rb +1 -1
- data/setsuzoku.gemspec +1 -1
- metadata +13 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 323e5a4555c1f507e09e4c37a03c17dd0d8be3a9178a103a63472e6a4b5182f7
|
4
|
+
data.tar.gz: f70654328bbe20500bdc1c4f59e5077633fcaf353e8726d84e9d2918cdf1aef2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 57c8ceaf5f4d4cfdb202126038cfc7e2095d251d5d68bf765663500ac3780b2611295a2df27d970e605cf2aa522de5bd58c5e116d59a3a66369f699f5825fd68
|
7
|
+
data.tar.gz: e81190b2aca16f38d15002c7d52ceff0541d2a81ca25eb31b8fd497b814db479a81ef71e997515a5358c7907f1ba74b132e0af688fcf2b4e8d6565420ec0ebac
|
data/Gemfile.lock
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
setsuzoku (0.
|
5
|
-
activesupport (
|
4
|
+
setsuzoku (0.14.0)
|
5
|
+
activesupport (>= 5.0, < 7)
|
6
6
|
faraday (~> 0.11)
|
7
7
|
nokogiri (~> 1.10)
|
8
8
|
sorbet-runtime (~> 0.5)
|
@@ -10,28 +10,31 @@ PATH
|
|
10
10
|
GEM
|
11
11
|
remote: https://rubygems.org/
|
12
12
|
specs:
|
13
|
-
activesupport (
|
13
|
+
activesupport (6.1.4)
|
14
14
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
15
|
-
i18n (>=
|
16
|
-
minitest (
|
17
|
-
tzinfo (~>
|
15
|
+
i18n (>= 1.6, < 2)
|
16
|
+
minitest (>= 5.1)
|
17
|
+
tzinfo (~> 2.0)
|
18
|
+
zeitwerk (~> 2.3)
|
18
19
|
addressable (2.7.0)
|
19
20
|
public_suffix (>= 2.0.2, < 5.0)
|
20
|
-
concurrent-ruby (1.1.
|
21
|
+
concurrent-ruby (1.1.9)
|
21
22
|
crack (0.4.3)
|
22
23
|
safe_yaml (~> 1.0.0)
|
23
24
|
diff-lcs (1.4.2)
|
24
|
-
faraday (0.17.
|
25
|
+
faraday (0.17.4)
|
25
26
|
multipart-post (>= 1.2, < 3)
|
26
27
|
hashdiff (1.0.1)
|
27
|
-
i18n (1.8.
|
28
|
+
i18n (1.8.10)
|
28
29
|
concurrent-ruby (~> 1.0)
|
29
|
-
mini_portile2 (2.
|
30
|
-
minitest (5.14.
|
30
|
+
mini_portile2 (2.5.3)
|
31
|
+
minitest (5.14.4)
|
31
32
|
multipart-post (2.1.1)
|
32
|
-
nokogiri (1.
|
33
|
-
mini_portile2 (~> 2.
|
33
|
+
nokogiri (1.11.7)
|
34
|
+
mini_portile2 (~> 2.5.0)
|
35
|
+
racc (~> 1.4)
|
34
36
|
public_suffix (4.0.5)
|
37
|
+
racc (1.5.2)
|
35
38
|
rake (10.5.0)
|
36
39
|
rspec (3.8.0)
|
37
40
|
rspec-core (~> 3.8.0)
|
@@ -49,15 +52,15 @@ GEM
|
|
49
52
|
safe_yaml (1.0.5)
|
50
53
|
sorbet (0.5.5675)
|
51
54
|
sorbet-static (= 0.5.5675)
|
52
|
-
sorbet-runtime (0.5.
|
55
|
+
sorbet-runtime (0.5.6466)
|
53
56
|
sorbet-static (0.5.5675-universal-darwin-14)
|
54
|
-
|
55
|
-
|
56
|
-
thread_safe (~> 0.1)
|
57
|
+
tzinfo (2.0.4)
|
58
|
+
concurrent-ruby (~> 1.0)
|
57
59
|
webmock (3.8.0)
|
58
60
|
addressable (>= 2.3.6)
|
59
61
|
crack (>= 0.3.2)
|
60
62
|
hashdiff (>= 0.4.0, < 2.0.0)
|
63
|
+
zeitwerk (2.4.2)
|
61
64
|
|
62
65
|
PLATFORMS
|
63
66
|
ruby
|
@@ -65,12 +65,12 @@ module Setsuzoku
|
|
65
65
|
image = open(url, 'rb')
|
66
66
|
Faraday::UploadIO.new(image, T.must(image).content_type, File.basename(url))
|
67
67
|
end
|
68
|
-
payload[options[:attachment_url_key]] = attachments
|
69
68
|
if request_properties[:request_format] == :json
|
70
69
|
payload[:json] = Faraday::UploadIO.new(StringIO.new(full_request), 'application/json')
|
71
70
|
else
|
72
71
|
payload.merge!(full_request)
|
73
72
|
end
|
73
|
+
payload[options[:attachment_url_key]] = attachments
|
74
74
|
req.body = payload
|
75
75
|
end
|
76
76
|
else
|
@@ -147,7 +147,7 @@ module Setsuzoku
|
|
147
147
|
.merge!(self.auth_strategy.get_from_context(:auth_headers).except(:authorization))
|
148
148
|
.merge!(self.get_from_context(:api_headers))
|
149
149
|
.merge!(action_details[:request_options] || {})
|
150
|
-
request_options[:authorization] = self.auth_strategy.get_from_context(:auth_headers)[:authorization]
|
150
|
+
request_options[:authorization] = action_details[:authorization] || self.auth_strategy.get_from_context(:auth_headers)[:authorization]
|
151
151
|
|
152
152
|
content_type = case request_format
|
153
153
|
when :json
|
@@ -86,6 +86,16 @@ module Setsuzoku
|
|
86
86
|
convert_xml_to_hash(response.body)
|
87
87
|
when :html
|
88
88
|
response.body
|
89
|
+
when :txt, :png, :jpg, :gif
|
90
|
+
# for now just return the file
|
91
|
+
response.body
|
92
|
+
# for now just put in tmp
|
93
|
+
# tmp_dir = "#{Dir.tmpdir}/setsuzoku/#{self.plugin.class.system_name.underscore}/#{self.plugin.name.underscore}"
|
94
|
+
# file_name = "#{self.plugin.class.system_name.underscore}_#{self.plugin.name.underscore}_#{Time.now.strftime("%Y_%m_%d_%T")}"
|
95
|
+
# t = Tempfile.new([file_name, ".#{options[:response_type]}"], encoding: 'ascii-8bit')
|
96
|
+
# t.write(response.body)
|
97
|
+
# t.rewind
|
98
|
+
# t
|
89
99
|
else
|
90
100
|
JSON.parse(response.body).deep_symbolize_keys
|
91
101
|
end
|
@@ -137,37 +137,27 @@ module Setsuzoku
|
|
137
137
|
# @return void
|
138
138
|
def get_token!(body, action)
|
139
139
|
success = false
|
140
|
-
|
140
|
+
without_headers = self.credential.auth_actions[action].has_key?(:without_headers) ? self.credential.auth_actions[action][:without_headers] : true
|
141
|
+
request = self.api_strategy.request_class.new(action: action, body: body, without_headers: without_headers)
|
141
142
|
|
142
143
|
resp = self.api_strategy.call_external_api(request: request, strategy: :auth)
|
143
144
|
|
144
145
|
return false unless resp.success
|
145
146
|
|
146
|
-
|
147
|
-
attrs[:status] = if attrs[:token]
|
148
|
-
'active'
|
149
|
-
else
|
150
|
-
'error'
|
151
|
-
end
|
152
|
-
|
153
|
-
# Assign any additional attributes the plugin's credential needs to know about.
|
154
|
-
# E.g. the extension for a phone_number.
|
155
|
-
plugin_attrs = self.credential.additional_attributes_to_assign(resp) if self.plugin.respond_to?(:credential_fields_to_update)
|
156
|
-
attrs.merge!(plugin_attrs) if plugin_attrs
|
157
|
-
|
158
|
-
# Only save Setsuzoku known fields, and any additional attributes the plugin specifies
|
159
|
-
# in credential_fields_to_update.
|
160
|
-
if self.credential.respond_to?(:"update_columns")
|
161
|
-
# we issue an update_columns instead of a save/update_attributes
|
162
|
-
# so as to only mutate these attributes
|
163
|
-
# and not any other fields that may have been set for the credential
|
164
|
-
save = self.credential.update_columns(attrs)
|
165
|
-
self.credential.touch if save && self.credential.respond_to?(:"touch")
|
166
|
-
save
|
167
|
-
else
|
168
|
-
true
|
169
|
-
end
|
147
|
+
self.credential.set_token!(resp)
|
170
148
|
end
|
149
|
+
|
150
|
+
#
|
151
|
+
# set_token!
|
152
|
+
sig { abstract.params(resp: Setsuzoku::ApiResponse, attrs: T::Hash[Symbol, T.untyped]).void }
|
153
|
+
#
|
154
|
+
# Persist relevant token and response data after authentication.
|
155
|
+
#
|
156
|
+
# @param resp [Setsuzoku::ApiResponse] the successful response for an authentication token.
|
157
|
+
# @param attrs [Hash] additional attrs that can be set by a specific credential implementation.
|
158
|
+
#
|
159
|
+
# @return [void]
|
160
|
+
def set_token!(resp, attrs = {}); end
|
171
161
|
end
|
172
162
|
end
|
173
163
|
end
|
@@ -54,26 +54,6 @@ module Setsuzoku
|
|
54
54
|
sig { abstract.returns(T.nilable(String)) }
|
55
55
|
def redirect_url; end
|
56
56
|
|
57
|
-
# The token, refresh_token, and expires_at to assign for an OAuth token request.
|
58
|
-
#
|
59
|
-
# @param resp [Hash] the response hash from the external api call for a token.
|
60
|
-
#
|
61
|
-
# @return [Hash] the attributes to assign to the credential.
|
62
|
-
sig{ override.params(resp: Setsuzoku::ApiResponse).returns(T::Hash[Symbol, T.untyped]) }
|
63
|
-
def token_attributes_to_assign(resp)
|
64
|
-
attrs = {
|
65
|
-
token: resp.data[:access_token],
|
66
|
-
refresh_token: resp.data[:refresh_token]
|
67
|
-
}
|
68
|
-
|
69
|
-
expires_in = resp.data[:expires_in]
|
70
|
-
if expires_in && (expires_in.is_a?(Integer) || expires_in.match(/^\d+$/))
|
71
|
-
attrs[:expires_on] = expires_in.to_i.seconds.from_now
|
72
|
-
end
|
73
|
-
|
74
|
-
attrs
|
75
|
-
end
|
76
|
-
|
77
57
|
# Stub an o_auth_credential-like instance.
|
78
58
|
#
|
79
59
|
# @return [Struct] a stubbed o_auth_credential-like struct.
|
@@ -51,16 +51,16 @@ module Setsuzoku
|
|
51
51
|
#
|
52
52
|
# @return [Datetime] the time to set for the current token's expiry.
|
53
53
|
sig{ abstract.params(val: DateTime).returns(T.nilable(DateTime)) }
|
54
|
-
def expires_on=(val);
|
54
|
+
def expires_on=(val); end
|
55
55
|
|
56
|
-
#
|
56
|
+
# Alternatively, a credential can manually handle what to do with a token response.
|
57
|
+
# For instance, storing multiple tokens as sub-resources
|
57
58
|
#
|
58
59
|
# @param resp [Hash] the response hash from the external api call for a token.
|
59
60
|
#
|
60
61
|
# @return [Hash] the attributes to assign to the credential.
|
61
|
-
sig{ abstract.params(resp: T::Hash[Symbol, T.untyped]).
|
62
|
-
def
|
63
|
-
end
|
62
|
+
sig{ abstract.params(resp: T::Hash[Symbol, T.untyped]).void }
|
63
|
+
def set_token!; end
|
64
64
|
end
|
65
65
|
end
|
66
66
|
end
|
data/lib/setsuzoku/version.rb
CHANGED
data/setsuzoku.gemspec
CHANGED
@@ -40,7 +40,7 @@ Gem::Specification.new do |spec|
|
|
40
40
|
spec.add_development_dependency "rake", "~> 10.0"
|
41
41
|
spec.add_development_dependency "rspec", "3.8"
|
42
42
|
spec.add_development_dependency "webmock", "3.8"
|
43
|
-
spec.add_runtime_dependency "activesupport", "
|
43
|
+
spec.add_runtime_dependency "activesupport", ">= 5.0", '< 7'
|
44
44
|
spec.add_development_dependency "sorbet", "~> 0.5"
|
45
45
|
spec.add_runtime_dependency "sorbet-runtime", "~> 0.5"
|
46
46
|
#TODO: we should remove httparty if we can just use faraday
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: setsuzoku
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.14.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luke Stadtler
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-06-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -70,16 +70,22 @@ dependencies:
|
|
70
70
|
name: activesupport
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - "
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '5.0'
|
76
|
+
- - "<"
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '7'
|
76
79
|
type: :runtime
|
77
80
|
prerelease: false
|
78
81
|
version_requirements: !ruby/object:Gem::Requirement
|
79
82
|
requirements:
|
80
|
-
- - "
|
83
|
+
- - ">="
|
81
84
|
- !ruby/object:Gem::Version
|
82
85
|
version: '5.0'
|
86
|
+
- - "<"
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '7'
|
83
89
|
- !ruby/object:Gem::Dependency
|
84
90
|
name: sorbet
|
85
91
|
requirement: !ruby/object:Gem::Requirement
|
@@ -221,7 +227,7 @@ homepage: https://github.com/rocketreferrals/setsuzoku
|
|
221
227
|
licenses:
|
222
228
|
- MIT
|
223
229
|
metadata: {}
|
224
|
-
post_install_message:
|
230
|
+
post_install_message:
|
225
231
|
rdoc_options: []
|
226
232
|
require_paths:
|
227
233
|
- lib
|
@@ -237,7 +243,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
237
243
|
version: '0'
|
238
244
|
requirements: []
|
239
245
|
rubygems_version: 3.0.1
|
240
|
-
signing_key:
|
246
|
+
signing_key:
|
241
247
|
specification_version: 4
|
242
248
|
summary: Extensible 3rd-party interface and functionality plugins
|
243
249
|
test_files: []
|