hydra-keycloak-client 0.1.18 → 0.1.20
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/.github/workflows/main.yml +1 -1
- data/Gemfile.lock +77 -63
- data/lib/hydra/keycloak/client.rb +3 -8
- data/lib/hydra/keycloak/store/memcached_client.rb +6 -3
- data/lib/hydra/keycloak/store/redis_client.rb +6 -3
- data/lib/hydra/keycloak/tokens/gateway.rb +3 -2
- data/lib/hydra/keycloak/tokens/repo.rb +6 -3
- data/lib/hydra/keycloak/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: 35234032d35ae9df65326d2fcf5aff4069ea07a297ce355f64076b3245d3a61a
|
4
|
+
data.tar.gz: '08998c74ca706bed47d8b99cb048c942f06f7e9a094482a1fee299dca932a00d'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ea3bba9ffc1c8829df7e38f6762ebf646aa6531a3a520eeab89e043e7fb74e220a88a50bb9af663c67c24a4efe1a7e318c01b3d45e2714494ea8fb99fafe42d3
|
7
|
+
data.tar.gz: 571e13491706bed3dd0e6e03b71cd8492217195f33fd56140735e16cbfdf56dbe0247d058c8882255a317e45343dac83c5ccd28378b78050c2eb4414ebf0c21d
|
data/.github/workflows/main.yml
CHANGED
@@ -23,7 +23,7 @@ jobs:
|
|
23
23
|
run: docker cp hkc_image:/app/coverage/coverage.xml coverage.xml
|
24
24
|
|
25
25
|
- name: "Upload coverage report"
|
26
|
-
run: pip install --user codecov==2.
|
26
|
+
run: pip install --user codecov==2.1.13 && python -m codecov --required --url="http://coverage.dev.latera.ru/api" --branch="${{ github.ref_name }}" --token="17989959" --slug="hydra-billing/hydra-keycloak-client"
|
27
27
|
|
28
28
|
- name: Clean up container
|
29
29
|
if: always()
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
hydra-keycloak-client (0.1.
|
4
|
+
hydra-keycloak-client (0.1.20)
|
5
5
|
dry-auto_inject
|
6
6
|
dry-container
|
7
7
|
dry-monads
|
@@ -13,91 +13,103 @@ GEM
|
|
13
13
|
remote: https://rubygems.org/
|
14
14
|
specs:
|
15
15
|
ast (2.4.2)
|
16
|
+
base64 (0.2.0)
|
16
17
|
coderay (1.1.3)
|
17
|
-
concurrent-ruby (1.2.
|
18
|
-
connection_pool (2.
|
19
|
-
dalli (3.2.
|
20
|
-
diff-lcs (1.5.
|
18
|
+
concurrent-ruby (1.2.3)
|
19
|
+
connection_pool (2.4.1)
|
20
|
+
dalli (3.2.8)
|
21
|
+
diff-lcs (1.5.1)
|
21
22
|
docile (1.4.0)
|
22
|
-
dry-auto_inject (0.
|
23
|
-
dry-
|
24
|
-
|
23
|
+
dry-auto_inject (1.0.1)
|
24
|
+
dry-core (~> 1.0)
|
25
|
+
zeitwerk (~> 2.6)
|
26
|
+
dry-configurable (1.0.1)
|
27
|
+
dry-core (~> 1.0, < 2)
|
28
|
+
zeitwerk (~> 2.6)
|
29
|
+
dry-container (0.11.0)
|
25
30
|
concurrent-ruby (~> 1.0)
|
26
|
-
|
27
|
-
dry-container (0.7.2)
|
31
|
+
dry-core (1.0.0)
|
28
32
|
concurrent-ruby (~> 1.0)
|
29
|
-
|
30
|
-
dry-
|
33
|
+
zeitwerk (~> 2.6)
|
34
|
+
dry-inflector (1.0.0)
|
35
|
+
dry-initializer (3.1.1)
|
36
|
+
dry-logic (1.5.0)
|
31
37
|
concurrent-ruby (~> 1.0)
|
32
|
-
|
33
|
-
|
34
|
-
dry-
|
35
|
-
dry-logic (1.2.0)
|
38
|
+
dry-core (~> 1.0, < 2)
|
39
|
+
zeitwerk (~> 2.6)
|
40
|
+
dry-monads (1.6.0)
|
36
41
|
concurrent-ruby (~> 1.0)
|
37
|
-
dry-core (~> 0
|
38
|
-
|
42
|
+
dry-core (~> 1.0, < 2)
|
43
|
+
zeitwerk (~> 2.6)
|
44
|
+
dry-schema (1.13.4)
|
39
45
|
concurrent-ruby (~> 1.0)
|
40
|
-
dry-
|
41
|
-
dry-
|
42
|
-
dry-schema (1.6.2)
|
43
|
-
concurrent-ruby (~> 1.0)
|
44
|
-
dry-configurable (~> 0.8, >= 0.8.3)
|
45
|
-
dry-core (~> 0.5, >= 0.5)
|
46
|
+
dry-configurable (~> 1.0, >= 1.0.1)
|
47
|
+
dry-core (~> 1.0, < 2)
|
46
48
|
dry-initializer (~> 3.0)
|
47
|
-
dry-logic (
|
48
|
-
dry-types (
|
49
|
-
|
50
|
-
|
51
|
-
dry-
|
49
|
+
dry-logic (>= 1.4, < 2)
|
50
|
+
dry-types (>= 1.7, < 2)
|
51
|
+
zeitwerk (~> 2.6)
|
52
|
+
dry-struct (1.6.0)
|
53
|
+
dry-core (~> 1.0, < 2)
|
54
|
+
dry-types (>= 1.7, < 2)
|
52
55
|
ice_nine (~> 0.11)
|
53
|
-
|
56
|
+
zeitwerk (~> 2.6)
|
57
|
+
dry-types (1.7.1)
|
54
58
|
concurrent-ruby (~> 1.0)
|
55
|
-
dry-
|
56
|
-
dry-
|
57
|
-
dry-
|
58
|
-
|
59
|
+
dry-core (~> 1.0)
|
60
|
+
dry-inflector (~> 1.0)
|
61
|
+
dry-logic (~> 1.4)
|
62
|
+
zeitwerk (~> 2.6)
|
59
63
|
ice_nine (0.11.2)
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
+
json (2.7.2)
|
65
|
+
jwt (2.8.1)
|
66
|
+
base64
|
67
|
+
language_server-protocol (3.17.0.3)
|
68
|
+
method_source (1.1.0)
|
69
|
+
parallel (1.24.0)
|
70
|
+
parser (3.3.1.0)
|
64
71
|
ast (~> 2.4.1)
|
72
|
+
racc
|
65
73
|
pry (0.14.2)
|
66
74
|
coderay (~> 1.1)
|
67
75
|
method_source (~> 1.0)
|
76
|
+
racc (1.8.0)
|
68
77
|
rainbow (3.1.1)
|
69
78
|
rake (12.3.3)
|
70
|
-
redis (5.0
|
71
|
-
redis-client (>= 0.
|
72
|
-
redis-client (0.
|
79
|
+
redis (5.2.0)
|
80
|
+
redis-client (>= 0.22.0)
|
81
|
+
redis-client (0.22.2)
|
73
82
|
connection_pool
|
74
|
-
regexp_parser (2.2
|
75
|
-
rexml (3.2.
|
76
|
-
|
77
|
-
|
78
|
-
rspec-
|
79
|
-
rspec-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
+
regexp_parser (2.9.2)
|
84
|
+
rexml (3.2.8)
|
85
|
+
strscan (>= 3.0.9)
|
86
|
+
rspec (3.13.0)
|
87
|
+
rspec-core (~> 3.13.0)
|
88
|
+
rspec-expectations (~> 3.13.0)
|
89
|
+
rspec-mocks (~> 3.13.0)
|
90
|
+
rspec-core (3.13.0)
|
91
|
+
rspec-support (~> 3.13.0)
|
92
|
+
rspec-expectations (3.13.0)
|
83
93
|
diff-lcs (>= 1.2.0, < 2.0)
|
84
|
-
rspec-support (~> 3.
|
85
|
-
rspec-mocks (3.
|
94
|
+
rspec-support (~> 3.13.0)
|
95
|
+
rspec-mocks (3.13.1)
|
86
96
|
diff-lcs (>= 1.2.0, < 2.0)
|
87
|
-
rspec-support (~> 3.
|
88
|
-
rspec-support (3.
|
89
|
-
rubocop (1.
|
97
|
+
rspec-support (~> 3.13.0)
|
98
|
+
rspec-support (3.13.1)
|
99
|
+
rubocop (1.64.0)
|
100
|
+
json (~> 2.3)
|
101
|
+
language_server-protocol (>= 3.17.0)
|
90
102
|
parallel (~> 1.10)
|
91
|
-
parser (>= 3.
|
103
|
+
parser (>= 3.3.0.2)
|
92
104
|
rainbow (>= 2.2.2, < 4.0)
|
93
105
|
regexp_parser (>= 1.8, < 3.0)
|
94
|
-
rexml
|
95
|
-
rubocop-ast (>= 1.
|
106
|
+
rexml (>= 3.2.5, < 4.0)
|
107
|
+
rubocop-ast (>= 1.31.1, < 2.0)
|
96
108
|
ruby-progressbar (~> 1.7)
|
97
|
-
unicode-display_width (>=
|
98
|
-
rubocop-ast (1.
|
99
|
-
parser (>= 3.
|
100
|
-
ruby-progressbar (1.
|
109
|
+
unicode-display_width (>= 2.4.0, < 3.0)
|
110
|
+
rubocop-ast (1.31.3)
|
111
|
+
parser (>= 3.3.1.0)
|
112
|
+
ruby-progressbar (1.13.0)
|
101
113
|
simplecov (0.22.0)
|
102
114
|
docile (~> 1.1)
|
103
115
|
simplecov-html (~> 0.11)
|
@@ -107,7 +119,9 @@ GEM
|
|
107
119
|
simplecov (~> 0.19)
|
108
120
|
simplecov-html (0.12.3)
|
109
121
|
simplecov_json_formatter (0.1.4)
|
110
|
-
|
122
|
+
strscan (3.1.0)
|
123
|
+
unicode-display_width (2.5.0)
|
124
|
+
zeitwerk (2.6.15)
|
111
125
|
|
112
126
|
PLATFORMS
|
113
127
|
ruby
|
@@ -177,14 +177,10 @@ module Hydra
|
|
177
177
|
|
178
178
|
def access_token(session_state)
|
179
179
|
fetch_token(session_state, 'access_token')
|
180
|
-
.or(Failure(code: :not_authenticated,
|
181
|
-
context: { args: { session_state: session_state } }))
|
182
180
|
end
|
183
181
|
|
184
182
|
def authorize!(session_state)
|
185
183
|
access_token = yield fetch_token(session_state, 'access_token')
|
186
|
-
.or(Failure(code: :not_authenticated,
|
187
|
-
context: { args: { session_state: session_state } }))
|
188
184
|
if token_expired?(access_token)
|
189
185
|
yield refresh_tokens(session_state)
|
190
186
|
|
@@ -195,9 +191,7 @@ module Hydra
|
|
195
191
|
end
|
196
192
|
|
197
193
|
def access_token_jti(session_state)
|
198
|
-
fetch_token(session_state, 'access_token')
|
199
|
-
.either(->(token) { Success(token[:jti]) },
|
200
|
-
->(_) { Failure(code: :not_authenticated, context: { args: { session_state: session_state } }) })
|
194
|
+
fetch_token(session_state, 'access_token').fmap { |token| token[:jti] }
|
201
195
|
end
|
202
196
|
|
203
197
|
def logout!(session_state)
|
@@ -225,7 +219,8 @@ module Hydra
|
|
225
219
|
else
|
226
220
|
Failure(code: :token_not_found,
|
227
221
|
context: { args: { session_state: session_state,
|
228
|
-
token_name: token_name }
|
222
|
+
token_name: token_name },
|
223
|
+
caller: caller })
|
229
224
|
end
|
230
225
|
end
|
231
226
|
end
|
@@ -16,13 +16,15 @@ module Hydra
|
|
16
16
|
|
17
17
|
Success(:ok)
|
18
18
|
rescue Dalli::DalliError => e
|
19
|
-
Failure(code: :memcached_unavailable,
|
19
|
+
Failure(code: :memcached_unavailable,
|
20
|
+
context: { args: { key: key }, action: :set, error: e.message, caller: caller })
|
20
21
|
end
|
21
22
|
|
22
23
|
def get(key)
|
23
24
|
Success(dalli.get(key))
|
24
25
|
rescue Dalli::DalliError => e
|
25
|
-
Failure(code: :memcached_unavailable,
|
26
|
+
Failure(code: :memcached_unavailable,
|
27
|
+
context: { args: { key: key }, action: :get, error: e.message, caller: caller })
|
26
28
|
end
|
27
29
|
|
28
30
|
def delete(key)
|
@@ -30,7 +32,8 @@ module Hydra
|
|
30
32
|
|
31
33
|
Success(:ok)
|
32
34
|
rescue Dalli::DalliError => e
|
33
|
-
Failure(code: :memcached_unavailable,
|
35
|
+
Failure(code: :memcached_unavailable,
|
36
|
+
context: { args: { key: key }, action: :delete, error: e.message, caller: caller })
|
34
37
|
end
|
35
38
|
end
|
36
39
|
end
|
@@ -16,13 +16,15 @@ module Hydra
|
|
16
16
|
|
17
17
|
Success(:ok)
|
18
18
|
rescue Redis::BaseError => e
|
19
|
-
Failure(code: :redis_unavailable,
|
19
|
+
Failure(code: :redis_unavailable,
|
20
|
+
context: { args: { key: key }, action: :set, error: e.message, caller: caller })
|
20
21
|
end
|
21
22
|
|
22
23
|
def get(key)
|
23
24
|
Success(redis.get(key))
|
24
25
|
rescue Redis::BaseError => e
|
25
|
-
Failure(code: :redis_unavailable,
|
26
|
+
Failure(code: :redis_unavailable,
|
27
|
+
context: { args: { key: key }, action: :get, error: e.message, caller: caller })
|
26
28
|
end
|
27
29
|
|
28
30
|
def delete(key)
|
@@ -30,7 +32,8 @@ module Hydra
|
|
30
32
|
|
31
33
|
Success(:ok)
|
32
34
|
rescue Redis::BaseError => e
|
33
|
-
Failure(code: :redis_unavailable,
|
35
|
+
Failure(code: :redis_unavailable,
|
36
|
+
context: { args: { key: key }, action: :delete, error: e.message, caller: caller })
|
34
37
|
end
|
35
38
|
end
|
36
39
|
end
|
@@ -40,18 +40,19 @@ module Hydra
|
|
40
40
|
Failure(code: :bad_keycloak_response,
|
41
41
|
context: { args: { path: path,
|
42
42
|
body: hide_secrets(body) },
|
43
|
+
caller: caller,
|
43
44
|
method: :post,
|
44
45
|
response: { code: response.code,
|
45
46
|
body: response.body } })
|
46
47
|
end
|
47
48
|
rescue *NETWORK_ERRORS => e
|
48
|
-
Failure(code: :keycloak_unavailable, context: { error: e.message })
|
49
|
+
Failure(code: :keycloak_unavailable, context: { error: e.message, caller: caller })
|
49
50
|
end
|
50
51
|
|
51
52
|
def parse_response(body)
|
52
53
|
Success(JSON.parse(body))
|
53
54
|
rescue JSON::ParserError => e
|
54
|
-
Failure(code: :json_parser_error, context: { args: { body: body }, error: e.message })
|
55
|
+
Failure(code: :json_parser_error, context: { args: { body: body }, error: e.message, caller: caller })
|
55
56
|
end
|
56
57
|
|
57
58
|
def hide_secrets(body)
|
@@ -14,7 +14,7 @@ module Hydra
|
|
14
14
|
inject['tokens_gateway', 'urls']
|
15
15
|
|
16
16
|
def get_tokens(auth_code, code_verifier)
|
17
|
-
return Failure(code: :auth_code_was_not_received) unless auth_code
|
17
|
+
return Failure(code: :auth_code_was_not_received, context: { caller: caller }) unless auth_code
|
18
18
|
|
19
19
|
result = tokens_gateway.post(
|
20
20
|
urls.token_endpoint,
|
@@ -31,7 +31,10 @@ module Hydra
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def get_tokens_by_password(username, password)
|
34
|
-
|
34
|
+
if username.nil? || password.nil?
|
35
|
+
return Failure(code: :username_or_password_is_empty,
|
36
|
+
context: { caller: caller })
|
37
|
+
end
|
35
38
|
|
36
39
|
result = tokens_gateway.post(
|
37
40
|
urls.token_endpoint,
|
@@ -55,7 +58,7 @@ module Hydra
|
|
55
58
|
if result['active']
|
56
59
|
Success(result)
|
57
60
|
else
|
58
|
-
Failure(code: :token_not_active)
|
61
|
+
Failure(code: :token_not_active, caller: caller)
|
59
62
|
end
|
60
63
|
end
|
61
64
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hydra-keycloak-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.20
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fedor Kosolapov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-03-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jwt
|