strongmind-platform-sdk 3.10.0 → 3.10.2
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/Gemfile.lock +23 -28
- data/lib/platform_sdk/identity/clients.rb +36 -8
- data/lib/platform_sdk/identity.rb +2 -0
- data/lib/platform_sdk/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fca9cc6c8dcf5d60413ccaade1fe75d0d1c3034984d26f4fbfd2a72ec7eeee6b
|
4
|
+
data.tar.gz: 66c6e120f49d0898618ca43879f09808b3e4042c25e3a57c14b5c65b21935372
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 74ca995cf7efa813996ff36cd0d260376a0964d54f30abaeecc90841ef2cd716c9ee58f2f2cf7af4546e65f5a21b0266930657b493c5c7e4556b25335e18402c
|
7
|
+
data.tar.gz: 4355b9b306fd3cbdae3bf12cf956677eb8ed58c4a276afc0abc5e8954c5f335c966518bac240f9fd5956d19651f99fa208108fb3ec7df2c996f921fb5a7961c5
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
strongmind-platform-sdk (3.10.
|
4
|
+
strongmind-platform-sdk (3.10.2)
|
5
5
|
aws-sdk-secretsmanager (~> 1.66)
|
6
6
|
devise
|
7
7
|
faraday (~> 2.5, >= 2.5.2)
|
@@ -19,38 +19,38 @@ PATH
|
|
19
19
|
GEM
|
20
20
|
remote: https://rubygems.org/
|
21
21
|
specs:
|
22
|
-
actionpack (7.
|
23
|
-
actionview (= 7.
|
24
|
-
activesupport (= 7.
|
25
|
-
rack (~> 2.0, >= 2.
|
22
|
+
actionpack (6.1.7.7)
|
23
|
+
actionview (= 6.1.7.7)
|
24
|
+
activesupport (= 6.1.7.7)
|
25
|
+
rack (~> 2.0, >= 2.0.9)
|
26
26
|
rack-test (>= 0.6.3)
|
27
27
|
rails-dom-testing (~> 2.0)
|
28
28
|
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
29
|
-
actionview (7.
|
30
|
-
activesupport (= 7.
|
29
|
+
actionview (6.1.7.7)
|
30
|
+
activesupport (= 6.1.7.7)
|
31
31
|
builder (~> 3.1)
|
32
32
|
erubi (~> 1.4)
|
33
33
|
rails-dom-testing (~> 2.0)
|
34
34
|
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
35
|
-
activemodel (7.
|
36
|
-
activesupport (= 7.
|
37
|
-
activesupport (7.
|
35
|
+
activemodel (6.1.7.7)
|
36
|
+
activesupport (= 6.1.7.7)
|
37
|
+
activesupport (6.1.7.7)
|
38
38
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
39
39
|
i18n (>= 1.6, < 2)
|
40
40
|
minitest (>= 5.1)
|
41
41
|
tzinfo (~> 2.0)
|
42
|
+
zeitwerk (~> 2.3)
|
42
43
|
addressable (2.8.6)
|
43
44
|
public_suffix (>= 2.0.2, < 6.0)
|
44
45
|
aes_key_wrap (1.1.0)
|
45
46
|
ast (2.4.2)
|
46
47
|
attr_required (1.0.2)
|
47
48
|
aws-eventstream (1.3.0)
|
48
|
-
aws-partitions (1.
|
49
|
-
aws-sdk-core (3.191.
|
49
|
+
aws-partitions (1.894.0)
|
50
|
+
aws-sdk-core (3.191.3)
|
50
51
|
aws-eventstream (~> 1, >= 1.3.0)
|
51
52
|
aws-partitions (~> 1, >= 1.651.0)
|
52
53
|
aws-sigv4 (~> 1.8)
|
53
|
-
base64
|
54
54
|
jmespath (~> 1, >= 1.6.1)
|
55
55
|
aws-sdk-secretsmanager (1.90.0)
|
56
56
|
aws-sdk-core (~> 3, >= 3.191.0)
|
@@ -62,7 +62,7 @@ GEM
|
|
62
62
|
bigdecimal (3.1.6)
|
63
63
|
bindata (2.5.0)
|
64
64
|
builder (3.2.4)
|
65
|
-
concurrent-ruby (1.2.
|
65
|
+
concurrent-ruby (1.2.3)
|
66
66
|
crack (1.0.0)
|
67
67
|
bigdecimal
|
68
68
|
rexml
|
@@ -80,9 +80,9 @@ GEM
|
|
80
80
|
erubi (1.12.0)
|
81
81
|
ethon (0.16.0)
|
82
82
|
ffi (>= 1.15.0)
|
83
|
-
factory_bot (6.
|
83
|
+
factory_bot (6.4.5)
|
84
84
|
activesupport (>= 5.0.0)
|
85
|
-
faker (
|
85
|
+
faker (2.22.0)
|
86
86
|
i18n (>= 1.8.11, < 2)
|
87
87
|
faraday (2.7.7)
|
88
88
|
faraday-net_http (>= 2.0, < 3.1)
|
@@ -95,11 +95,11 @@ GEM
|
|
95
95
|
ffi (1.15.5)
|
96
96
|
hashdiff (1.1.0)
|
97
97
|
hashie (5.0.0)
|
98
|
-
i18n (1.
|
98
|
+
i18n (1.14.1)
|
99
99
|
concurrent-ruby (~> 1.0)
|
100
100
|
jmespath (1.6.2)
|
101
101
|
json (2.6.3)
|
102
|
-
json-jwt (1.16.
|
102
|
+
json-jwt (1.16.6)
|
103
103
|
activesupport (>= 4.2)
|
104
104
|
aes_key_wrap
|
105
105
|
base64
|
@@ -120,7 +120,7 @@ GEM
|
|
120
120
|
method_source (1.0.0)
|
121
121
|
mini_mime (1.1.5)
|
122
122
|
mini_portile2 (2.8.5)
|
123
|
-
minitest (5.
|
123
|
+
minitest (5.22.2)
|
124
124
|
multi_json (1.15.0)
|
125
125
|
net-imap (0.4.10)
|
126
126
|
date
|
@@ -134,10 +134,6 @@ GEM
|
|
134
134
|
nokogiri (1.16.2)
|
135
135
|
mini_portile2 (~> 2.8.2)
|
136
136
|
racc (~> 1.4)
|
137
|
-
nokogiri (1.16.2-x86_64-darwin)
|
138
|
-
racc (~> 1.4)
|
139
|
-
nokogiri (1.16.2-x86_64-linux)
|
140
|
-
racc (~> 1.4)
|
141
137
|
omniauth (2.1.2)
|
142
138
|
hashie (>= 3.4.6)
|
143
139
|
rack (>= 2.2.3)
|
@@ -167,7 +163,7 @@ GEM
|
|
167
163
|
ast (~> 2.4.1)
|
168
164
|
public_suffix (5.0.4)
|
169
165
|
racc (1.7.3)
|
170
|
-
rack (2.2.8)
|
166
|
+
rack (2.2.8.1)
|
171
167
|
rack-oauth2 (2.2.1)
|
172
168
|
activesupport
|
173
169
|
attr_required
|
@@ -187,13 +183,12 @@ GEM
|
|
187
183
|
rails-html-sanitizer (1.6.0)
|
188
184
|
loofah (~> 2.21)
|
189
185
|
nokogiri (~> 1.14)
|
190
|
-
railties (7.
|
191
|
-
actionpack (= 7.
|
192
|
-
activesupport (= 7.
|
186
|
+
railties (6.1.7.7)
|
187
|
+
actionpack (= 6.1.7.7)
|
188
|
+
activesupport (= 6.1.7.7)
|
193
189
|
method_source
|
194
190
|
rake (>= 12.2)
|
195
191
|
thor (~> 1.0)
|
196
|
-
zeitwerk (~> 2.5)
|
197
192
|
rainbow (3.1.1)
|
198
193
|
rake (13.0.6)
|
199
194
|
regexp_parser (2.8.0)
|
@@ -37,11 +37,23 @@ module PlatformSdk
|
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
|
-
def
|
41
|
-
|
42
|
-
|
43
|
-
|
40
|
+
def with_rescue
|
41
|
+
yield
|
42
|
+
rescue Faraday::ServerError => e
|
43
|
+
raise_error_with_payload(IdentityServerError, e)
|
44
|
+
rescue Faraday::ClientError => e
|
45
|
+
raise_error_with_payload(IdentityClientError, e)
|
46
|
+
end
|
47
|
+
|
48
|
+
def post_payload(path, body)
|
49
|
+
with_rescue do
|
50
|
+
response = @conn.post(path, body)
|
51
|
+
response.body.transform_keys!(&:to_sym)
|
44
52
|
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def auth_token
|
56
|
+
@token = post_payload("/connect/token", request_body) if expired?
|
45
57
|
|
46
58
|
@token[:access_token]
|
47
59
|
end
|
@@ -65,19 +77,24 @@ module PlatformSdk
|
|
65
77
|
Time.at(JWT.decode(jwt, nil, false)[0]["exp"])
|
66
78
|
end
|
67
79
|
|
68
|
-
def
|
80
|
+
def refresh_token_if_expired(jwt:, refresh_token:)
|
69
81
|
raise ArgumentError if refresh_token.nil? || jwt.nil?
|
70
82
|
return unless token_expired?(jwt)
|
71
83
|
|
72
|
-
|
84
|
+
refresh_token(refresh_token)
|
85
|
+
end
|
86
|
+
|
87
|
+
def refresh_token(refresh_token)
|
88
|
+
raise ArgumentError if refresh_token.nil?
|
89
|
+
|
90
|
+
post_payload("/connect/token", request_body(
|
73
91
|
grant_type: "refresh_token", refresh_token:))
|
74
|
-
response.body.transform_keys!(&:to_sym)
|
75
92
|
end
|
76
93
|
|
77
94
|
def refresh_session(session: {})
|
78
95
|
raise ArgumentError if session[:access_token].nil? || session[:refresh_token].nil?
|
79
96
|
|
80
|
-
refreshed_tokens =
|
97
|
+
refreshed_tokens = refresh_token_if_expired(jwt: session[:access_token], refresh_token: session[:refresh_token])
|
81
98
|
|
82
99
|
return if refreshed_tokens.nil?
|
83
100
|
|
@@ -86,6 +103,17 @@ module PlatformSdk
|
|
86
103
|
session[:refresh_token] = refreshed_tokens[:refresh_token]
|
87
104
|
end
|
88
105
|
|
106
|
+
def raise_error_with_payload(exception_class, error)
|
107
|
+
json_log = {
|
108
|
+
exception: exception_class.new.class.name.demodulize,
|
109
|
+
payload: error.response.dig(:request, :body),
|
110
|
+
response_body: error.response[:body],
|
111
|
+
status: error.response[:status]
|
112
|
+
}.compact
|
113
|
+
Rails.logger.info json_log.to_json if respond_to?(:Rails)
|
114
|
+
raise exception_class, error.response
|
115
|
+
end
|
116
|
+
|
89
117
|
private
|
90
118
|
|
91
119
|
def request_body(grant_type: "client_credentials", refresh_token: nil)
|
data/lib/platform_sdk/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: strongmind-platform-sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.10.
|
4
|
+
version: 3.10.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Platform Team
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-03-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|