hydra-keycloak-client 0.1.18 → 0.1.19

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0a2e948b3a20ed2ba3bbbfa11c0d8095d1d2668ab7b84ab9c84ee141b4ffd858
4
- data.tar.gz: 470d447468b40bb7f22ba97126702a7c99952cf9038005097b44651ce900a0c3
3
+ metadata.gz: 53ac1a0505551350a5f1374aa7bd3fb390c68047b8be65e87ec00f6f36e6394a
4
+ data.tar.gz: 050da3e0481a21c09aa00410dcaf19b514bf23d6dfc868261d8205120898cd2e
5
5
  SHA512:
6
- metadata.gz: ce821ea5c0d68d23c1e57c5696013b4a3cdec84e4bd70e1ad484c2c394e1fa5699f7b685311732c4ed8d176406faeece9b78e722cb53fae7666c69e77cb9dfa5
7
- data.tar.gz: fdb9094dd2861753b689f2a83b367116460b49f0a3817d2ba01b1c2fcf5ea705d2e4c7f903b6131c6d137c2785a8e5572ed9c80f74959447a37e9238a2eadecb
6
+ metadata.gz: c4ae1d7d6ce9deb7c39c7a4b82d3e3a2caf8fd9a05d9d4a089929e62a98081020699808c21745045461c30a70fa690a6706232126fa100137fe9e37a2bd183d5
7
+ data.tar.gz: e7761077fd40bb285b57136fa6b800c5f393746a9e02aab44969f81bd19a9eb5ca3fd4aaefe31718680e987999688e217ec7f36fc14d2dd7c9f839f374522b83
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- hydra-keycloak-client (0.1.18)
4
+ hydra-keycloak-client (0.1.19)
5
5
  dry-auto_inject
6
6
  dry-container
7
7
  dry-monads
@@ -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, context: { args: { key: key }, action: :set, error: e.message })
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, context: { args: { key: key }, action: :get, error: e.message })
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, context: { args: { key: key }, action: :delete, error: e.message })
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, context: { args: { key: key }, action: :set, error: e.message })
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, context: { args: { key: key }, action: :get, error: e.message })
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, context: { args: { key: key }, action: :delete, error: e.message })
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
- return Failure(code: :username_or_password_is_empty) if username.nil? || password.nil?
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
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Hydra
4
4
  module Keycloak
5
- VERSION = '0.1.18'
5
+ VERSION = '0.1.19'
6
6
  end
7
7
  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.18
4
+ version: 0.1.19
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fedor Kosolapov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-02-27 00:00:00.000000000 Z
11
+ date: 2023-07-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jwt