hydra-keycloak-client 0.1.7 → 0.1.10

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: 291ce7dea090b7d863e9fd3d29c92bf035c64f940ef1b3c8d0fce955a54bf8fb
4
- data.tar.gz: 94f719f340181a2cd5c12bd2d5eb070d53c6c1d55dbd1161f49249d6fd66b895
3
+ metadata.gz: 516229617ccd659620dd11a197eadbb3d5f2085bd59afdc44371af351b013009
4
+ data.tar.gz: be901750b274b69fec1544e6268c0a0016d9b8ba254afec831215da440260de1
5
5
  SHA512:
6
- metadata.gz: 3198cc3b6df1e02af1686bdbdaa8f12dae01e47da07d20635ba843c5df4ac2de833c56c9c1629c0603856360345439bc2aeb34596f383a2853e1386d29ca672a
7
- data.tar.gz: b7f96f9134234bd3c337f8727409a9d1a984ab8d375a484b29b7c32e9721e4e6d82509cc0162490e5451599c98a895d84a17d9ab390a83559ec520b3276e74f3
6
+ metadata.gz: 01df11417b5231dc9651568b84c2c08f63580bfa1a7fcc951b169eddfeb4849ec833115416cb807f19ed6457445b7927e4d554cae6201811d4021d57616e2c19
7
+ data.tar.gz: 0f7af8f307e65ff7eae75bb5d9a5367c2af56a69f96b2d5723b6bb3e7ac54da5042ec499f84b2a741c55785a0cad2acef5c3e3b1d4d10939ccd0c48696d2ceea
@@ -12,5 +12,8 @@ jobs:
12
12
  - name: Build image
13
13
  run: docker build -f Dockerfile.test -t hkc_test_image .
14
14
 
15
+ - name: Run rubocop
16
+ run: docker run hkc_test_image rubocop
17
+
15
18
  - name: Run tests
16
19
  run: docker run hkc_test_image rspec
data/.rubocop.yml ADDED
@@ -0,0 +1,13 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.5.8
3
+ Exclude:
4
+ - 'spec/**/**/*'
5
+
6
+ Style/Documentation:
7
+ Enabled: false
8
+
9
+ Metrics/AbcSize:
10
+ Max: 50
11
+
12
+ Metrics/MethodLength:
13
+ Max: 30
data/Dockerfile.test CHANGED
@@ -4,4 +4,3 @@ COPY . /app
4
4
  WORKDIR /app
5
5
 
6
6
  RUN bundle install
7
- CMD bundle exec rspec
data/Gemfile CHANGED
@@ -1,9 +1,12 @@
1
- source "https://rubygems.org"
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
2
4
 
3
5
  # Specify your gem's dependencies in hydra-keycloak-client.gemspec
4
6
  gemspec
5
7
 
6
- gem "rake", "~> 12.0"
7
- gem "rspec", "~> 3.0"
8
+ gem 'rake', '~> 12.0'
9
+ gem 'rspec', '~> 3.0'
10
+ gem 'rubocop', '~> 1.26'
8
11
 
9
12
  gem 'pry'
data/Gemfile.lock CHANGED
@@ -1,22 +1,20 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- hydra-keycloak-client (0.1.7)
5
- dalli
4
+ hydra-keycloak-client (0.1.9)
6
5
  dry-auto_inject
7
6
  dry-container
8
7
  dry-monads
9
8
  dry-schema
10
9
  dry-struct
11
10
  jwt
12
- redis
13
11
 
14
12
  GEM
15
13
  remote: https://rubygems.org/
16
14
  specs:
15
+ ast (2.4.2)
17
16
  coderay (1.1.3)
18
17
  concurrent-ruby (1.1.9)
19
- dalli (3.2.1)
20
18
  diff-lcs (1.4.4)
21
19
  dry-auto_inject (0.9.0)
22
20
  dry-container (>= 0.3.4)
@@ -56,11 +54,16 @@ GEM
56
54
  ice_nine (0.11.2)
57
55
  jwt (2.3.0)
58
56
  method_source (1.0.0)
57
+ parallel (1.21.0)
58
+ parser (3.1.1.0)
59
+ ast (~> 2.4.1)
59
60
  pry (0.14.1)
60
61
  coderay (~> 1.1)
61
62
  method_source (~> 1.0)
63
+ rainbow (3.1.1)
62
64
  rake (12.3.3)
63
- redis (4.6.0)
65
+ regexp_parser (2.2.1)
66
+ rexml (3.2.5)
64
67
  rspec (3.10.0)
65
68
  rspec-core (~> 3.10.0)
66
69
  rspec-expectations (~> 3.10.0)
@@ -74,6 +77,19 @@ GEM
74
77
  diff-lcs (>= 1.2.0, < 2.0)
75
78
  rspec-support (~> 3.10.0)
76
79
  rspec-support (3.10.3)
80
+ rubocop (1.26.0)
81
+ parallel (~> 1.10)
82
+ parser (>= 3.1.0.0)
83
+ rainbow (>= 2.2.2, < 4.0)
84
+ regexp_parser (>= 1.8, < 3.0)
85
+ rexml
86
+ rubocop-ast (>= 1.16.0, < 2.0)
87
+ ruby-progressbar (~> 1.7)
88
+ unicode-display_width (>= 1.4.0, < 3.0)
89
+ rubocop-ast (1.16.0)
90
+ parser (>= 3.1.1.0)
91
+ ruby-progressbar (1.11.0)
92
+ unicode-display_width (2.1.0)
77
93
 
78
94
  PLATFORMS
79
95
  ruby
@@ -83,6 +99,7 @@ DEPENDENCIES
83
99
  pry
84
100
  rake (~> 12.0)
85
101
  rspec (~> 3.0)
102
+ rubocop (~> 1.26)
86
103
 
87
104
  BUNDLED WITH
88
105
  2.2.25
data/README.md CHANGED
@@ -40,7 +40,7 @@ or for memcached:
40
40
 
41
41
  ```
42
42
  ...
43
- store_client: 'redis',
43
+ store_client: 'memcached',
44
44
  store_client_options: {
45
45
  memcached_host: "localhost",
46
46
  memcached_port: "11211",
data/Rakefile CHANGED
@@ -1,6 +1,8 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
3
5
 
4
6
  RSpec::Core::RakeTask.new(:spec)
5
7
 
6
- task :default => :spec
8
+ task default: :spec
data/bin/console CHANGED
@@ -1,7 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
- require "bundler/setup"
4
- require "hydra/keycloak/client"
4
+ require 'bundler/setup'
5
+ require 'hydra/keycloak/client'
5
6
 
6
7
  # You can add fixtures and/or initialization code here to make experimenting
7
8
  # with your gem easier. You can also use a different console, if you like.
@@ -10,5 +11,5 @@ require "hydra/keycloak/client"
10
11
  # require "pry"
11
12
  # Pry.start
12
13
 
13
- require "irb"
14
+ require 'irb'
14
15
  IRB.start(__FILE__)
@@ -1,38 +1,38 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require './lib/hydra/keycloak/version'
2
4
 
3
5
  Gem::Specification.new do |spec|
4
- spec.require_paths = ["lib"]
5
- spec.name = "hydra-keycloak-client"
6
+ spec.require_paths = ['lib']
7
+ spec.name = 'hydra-keycloak-client'
6
8
  spec.version = Hydra::Keycloak::VERSION
7
- spec.authors = ["Fedor Kosolapov"]
8
- spec.email = ["f.kosolapov@latera.ru"]
9
+ spec.authors = ['Fedor Kosolapov']
10
+ spec.email = ['f.kosolapov@latera.ru']
9
11
 
10
- spec.summary = "Keycloak client for SSO"
11
- spec.description = "Keycloak client for SSO"
12
- spec.homepage = "https://github.com/latera/hydra-keycloak-client"
13
- spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
12
+ spec.summary = 'Keycloak client for SSO'
13
+ spec.description = 'Keycloak client for SSO'
14
+ spec.homepage = 'https://github.com/latera/hydra-keycloak-client'
15
+ spec.required_ruby_version = Gem::Requirement.new('>= 2.5.8')
14
16
 
15
- spec.metadata["allowed_push_host"] = "https://rubygems.org"
17
+ spec.metadata['allowed_push_host'] = 'https://rubygems.org'
16
18
 
17
- spec.metadata["homepage_uri"] = spec.homepage
18
- spec.metadata["source_code_uri"] = spec.homepage
19
- spec.metadata["changelog_uri"] = spec.homepage
19
+ spec.metadata['homepage_uri'] = spec.homepage
20
+ spec.metadata['source_code_uri'] = spec.homepage
21
+ spec.metadata['changelog_uri'] = spec.homepage
20
22
 
21
23
  # Specify which files should be added to the gem when it is released.
22
24
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
23
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
25
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
24
26
  `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
25
27
  end
26
- spec.bindir = "bin"
28
+ spec.bindir = 'bin'
27
29
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
28
30
 
29
31
  spec.add_dependency('jwt')
30
- spec.add_dependency('dalli')
31
- spec.add_dependency('redis')
32
32
 
33
- spec.add_dependency('dry-monads')
34
33
  spec.add_dependency('dry-auto_inject')
35
34
  spec.add_dependency('dry-container')
35
+ spec.add_dependency('dry-monads')
36
36
  spec.add_dependency('dry-schema')
37
37
  spec.add_dependency('dry-struct')
38
38
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'dry/monads'
3
4
  require 'dry/auto_inject'
4
5
  require 'dry/container'
@@ -14,85 +15,119 @@ module Hydra
14
15
  class ClientCreator
15
16
  extend ::Hydra::Keycloak::Mixin
16
17
 
17
- def self.call(config:)
18
- memcached_schema = Dry::Schema.JSON do
19
- required(:memcached_host).filled(:string)
20
- required(:memcached_port).filled(:string)
21
- required(:memcached_namespace).filled(:string)
18
+ class << self
19
+ def call(config:)
20
+ register_containers(validate_config(config))
22
21
  end
23
22
 
24
- redis_schema = Dry::Schema.JSON do
25
- required(:redis_host).filled(:string)
26
- required(:redis_port).filled(:string)
27
- end
23
+ def validate_config(config)
24
+ validated_config = config_schema.call(config)
25
+
26
+ if validated_config.failure?
27
+ raise ConfigurationError, "Wrong configuration params: #{validated_config.errors(full: true).to_h}"
28
+ end
28
29
 
29
- config_schema = Dry::Schema.JSON do
30
- required(:auth_server_url).filled(:string)
31
- required(:realm).filled(:string)
32
- required(:client_id).filled(:string)
33
- required(:redirect_uri).filled(:string)
34
- required(:secret).filled(:string)
35
- required(:logout_redirect).filled(:string)
36
- required(:store_client).value(included_in?: ['redis', 'memcached'])
37
- required(:store_client_options).hash(memcached_schema | redis_schema)
30
+ validated_config
31
+ end
32
+
33
+ def config_schema
34
+ memcached_schema = ::Hydra::Keycloak::ClientCreator.memcached_schema
35
+ redis_schema = ::Hydra::Keycloak::ClientCreator.redis_schema
36
+ Dry::Schema.JSON do
37
+ required(:auth_server_url).filled(:string)
38
+ required(:realm).filled(:string)
39
+ required(:client_id).filled(:string)
40
+ required(:redirect_uri).filled(:string)
41
+ required(:secret).filled(:string)
42
+ required(:logout_redirect).filled(:string)
43
+ required(:store_client).value(included_in?: %w[redis memcached])
44
+ required(:store_client_options).hash(memcached_schema | redis_schema)
45
+ end
38
46
  end
39
47
 
40
- validated_config = config_schema.call(config)
48
+ def memcached_schema
49
+ Dry::Schema.JSON do
50
+ required(:memcached_host).filled(:string)
51
+ required(:memcached_port).filled(:string)
52
+ required(:memcached_namespace).filled(:string)
53
+ end
54
+ end
41
55
 
42
- if validated_config.failure?
43
- raise ConfigurationError, "Wrong configuration params: #{validated_config.errors(full: true).to_h}"
56
+ def redis_schema
57
+ Dry::Schema.JSON do
58
+ required(:redis_host).filled(:string)
59
+ required(:redis_port).filled(:string)
60
+ end
44
61
  end
45
62
 
46
- container.register :urls do
47
- require 'hydra/keycloak/urls'
63
+ def register_containers(validated_config)
64
+ register_urls(validated_config)
65
+ register_queries
66
+ register_store_client(validated_config)
67
+ register_store
68
+ register_code_verifier
48
69
 
49
- ::Hydra::Keycloak::Urls.new(validated_config)
70
+ ::Hydra::Keycloak::Client.new
50
71
  end
51
72
 
52
- container.register :queries do
53
- require 'hydra/keycloak/queries/gateway'
73
+ def register_urls(config)
74
+ container.register :urls do
75
+ require 'hydra/keycloak/urls'
54
76
 
55
- ::Hydra::Keycloak::Queries::Gateway.new
77
+ ::Hydra::Keycloak::Urls.new(config)
78
+ end
56
79
  end
57
80
 
58
- if validated_config[:store_client] == 'redis'
59
- container.register :redis do
60
- require 'redis'
61
-
62
- ::Redis.new(host: validated_config[:redis_host], port: validated_config[:redis_port])
63
- end
64
-
65
- container.register :store_client do
66
- require 'hydra/keycloak/store/redis_client'
67
-
68
- ::Hydra::Keycloak::Store::RedisClient.new
69
- end
70
- elsif validated_config[:store_client] == 'memcached'
71
- container.register :dalli do
72
- require 'dalli'
73
-
74
- ::Dalli::Client.new(
75
- "#{validated_config[:store_client_options][:memcached_host]}:#{validated_config[:store_client_options][:memcached_port]}",
76
- namespace: validated_config[:store_client_options][:memcached_namespace]
77
- )
78
- end
79
-
80
- container.register :store_client do
81
- require 'hydra/keycloak/store/memcached_client'
82
-
83
- ::Hydra::Keycloak::Store::MemcachedClient.new
81
+ def register_queries
82
+ container.register :queries do
83
+ require 'hydra/keycloak/queries/gateway'
84
+
85
+ ::Hydra::Keycloak::Queries::Gateway.new
84
86
  end
85
- end
87
+ end
88
+
89
+ def register_store_client(config)
90
+ case config[:store_client]
91
+ when 'redis'
92
+ require 'hydra/keycloak/store/adapters/redis'
86
93
 
87
- container.register :store do
88
- require 'hydra/keycloak/store/gateway'
94
+ container.register :redis do
95
+ ::Redis.new(host: config[:redis_host], port: config[:redis_port])
96
+ end
89
97
 
90
- ::Hydra::Keycloak::Store::Gateway.new
98
+ container.register :store_client do
99
+ require 'hydra/keycloak/store/redis_client'
100
+
101
+ ::Hydra::Keycloak::Store::RedisClient.new
102
+ end
103
+ when 'memcached'
104
+ require 'hydra/keycloak/store/adapters/memcached'
105
+ container.register :dalli do
106
+ ::Dalli::Client.new(
107
+ "#{config[:store_client_options][:memcached_host]}:#{config[:store_client_options][:memcached_port]}",
108
+ namespace: config[:store_client_options][:memcached_namespace]
109
+ )
110
+ end
111
+
112
+ container.register :store_client do
113
+ require 'hydra/keycloak/store/memcached_client'
114
+
115
+ ::Hydra::Keycloak::Store::MemcachedClient.new
116
+ end
117
+ end
91
118
  end
92
119
 
93
- container.register(:code_verifier, ::Hydra::Keycloak::CodeVerifier.new)
120
+ def register_store
121
+ container.register :store do
122
+ require 'hydra/keycloak/store/gateway'
94
123
 
95
- ::Hydra::Keycloak::Client.new
124
+ ::Hydra::Keycloak::Store::Gateway.new
125
+ end
126
+ end
127
+
128
+ def register_code_verifier
129
+ container.register(:code_verifier, ::Hydra::Keycloak::CodeVerifier.new)
130
+ end
96
131
  end
97
132
  end
98
133
 
@@ -107,9 +142,7 @@ module Hydra
107
142
  end
108
143
 
109
144
  def authenticate!(auth_code)
110
- unless auth_code
111
- return Failure(status: 400, code: :auth_code_was_not_received)
112
- end
145
+ return Failure(status: 400, code: :auth_code_was_not_received) unless auth_code
113
146
 
114
147
  queries.get_tokens(auth_code, code_verifier.value).fmap do |tokens|
115
148
  access_token = tokens[:access_token]
@@ -131,17 +164,13 @@ module Hydra
131
164
  end
132
165
 
133
166
  def access_token(session_state)
134
- unless authenticated?(session_state)
135
- return Failure(status: 400, code: :not_authenticated)
136
- end
167
+ return Failure(status: 400, code: :not_authenticated) unless authenticated?(session_state)
137
168
 
138
169
  fetch_token(session_state, 'access_token')
139
170
  end
140
171
 
141
172
  def authorize!(session_state)
142
- unless authenticated?(session_state)
143
- return Failure(status: 400, code: :not_authenticated)
144
- end
173
+ return Failure(status: 400, code: :not_authenticated) unless authenticated?(session_state)
145
174
 
146
175
  access_token = yield fetch_token(session_state, 'access_token')
147
176
  if token_expired?(access_token)
@@ -154,13 +183,9 @@ module Hydra
154
183
  end
155
184
 
156
185
  def access_token_jti(session_state)
157
- unless authenticated?(session_state)
158
- return Failure(status: 400, code: :not_authenticated)
159
- end
186
+ return Failure(status: 400, code: :not_authenticated) unless authenticated?(session_state)
160
187
 
161
- fetch_token(session_state, 'access_token').fmap do |access_token|
162
- access_token.jti
163
- end
188
+ fetch_token(session_state, 'access_token').fmap(&:jti)
164
189
  end
165
190
 
166
191
  def logout!(session_state)
@@ -171,6 +196,10 @@ module Hydra
171
196
  end
172
197
  end
173
198
 
199
+ def introspect_token(token)
200
+ queries.token_introspect(token)
201
+ end
202
+
174
203
  private
175
204
 
176
205
  def save_token(session_state, token_name, token)
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "digest"
4
- require "securerandom"
3
+ require 'digest'
4
+ require 'securerandom'
5
5
 
6
6
  require 'hydra/keycloak/container'
7
7
 
@@ -9,24 +9,24 @@ module Hydra
9
9
  module Keycloak
10
10
  class CodeVerifier
11
11
  attr_reader :value, :code_challenge
12
-
12
+
13
13
  def generate
14
14
  @value = _generate
15
15
  @code_challenge = _generate_pkce(@value)
16
16
  end
17
-
17
+
18
18
  private
19
-
19
+
20
20
  def _generate
21
21
  # https://datatracker.ietf.org/doc/html/rfc7636#section-4.1
22
22
  charset = Array('A'..'Z') + Array('a'..'z') + Array(0..9)
23
- charset.push("-").push(".").push("_").push("~")
23
+ charset.push('-').push('.').push('_').push('~')
24
24
  Array.new(128) { charset.sample }.join
25
25
  end
26
26
 
27
27
  def _generate_pkce(code_verifier)
28
28
  # https://datatracker.ietf.org/doc/html/rfc7636#section-4.6
29
- Digest::SHA256.base64digest(code_verifier).tr("+/", "-_").tr("=", "")
29
+ Digest::SHA256.base64digest(code_verifier).tr('+/', '-_').tr('=', '')
30
30
  end
31
31
  end
32
32
  end
@@ -19,11 +19,11 @@ module Hydra
19
19
 
20
20
  class << self
21
21
  def inject(target)
22
- -> *values { target.send(:include, Import[*values]) }
22
+ ->(*values) { target.send(:include, Import[*values]) }
23
23
  end
24
-
24
+
25
25
  def args_inject(target)
26
- -> *values { target.send(:include, Import.args[*values]) }
26
+ ->(*values) { target.send(:include, Import.args[*values]) }
27
27
  end
28
28
  end
29
29
 
@@ -31,11 +31,11 @@ module Hydra
31
31
  def container
32
32
  ::Hydra::Keycloak::Container
33
33
  end
34
-
34
+
35
35
  def inject
36
36
  ::Hydra::Keycloak.inject(self)
37
37
  end
38
-
38
+
39
39
  def args_inject
40
40
  ::Hydra::Keycloak.args_inject(self)
41
41
  end
@@ -19,8 +19,8 @@ module Hydra
19
19
 
20
20
  result.fmap do |tokens|
21
21
  {
22
- access_token: ::Hydra::Keycloak::Token.new(tokens['access_token']),
23
- id_token: ::Hydra::Keycloak::Token.new(tokens['id_token']),
22
+ access_token: ::Hydra::Keycloak::Token.new(tokens['access_token']),
23
+ id_token: ::Hydra::Keycloak::Token.new(tokens['id_token']),
24
24
  refresh_token: ::Hydra::Keycloak::Token.new(tokens['refresh_token'])
25
25
  }
26
26
  end
@@ -44,10 +44,10 @@ module Hydra
44
44
  Failure(status: 400, code: :token_refreshing_error)
45
45
  else
46
46
  Success({
47
- access_token: ::Hydra::Keycloak::Token.new(result['access_token']),
48
- id_token: ::Hydra::Keycloak::Token.new(result['id_token']),
49
- refresh_token: ::Hydra::Keycloak::Token.new(result['refresh_token'])
50
- })
47
+ access_token: ::Hydra::Keycloak::Token.new(result['access_token']),
48
+ id_token: ::Hydra::Keycloak::Token.new(result['id_token']),
49
+ refresh_token: ::Hydra::Keycloak::Token.new(result['refresh_token'])
50
+ })
51
51
  end
52
52
  end
53
53
  end
@@ -10,14 +10,14 @@ module Hydra
10
10
  class HttpClient
11
11
  include ::Dry::Monads[:result]
12
12
 
13
- NetworkErrors = [Timeout::Error,
14
- Errno::EINVAL,
15
- Errno::ECONNRESET,
16
- EOFError,
17
- Errno::ECONNREFUSED,
18
- Net::HTTPBadResponse,
19
- Net::HTTPHeaderSyntaxError,
20
- Net::ProtocolError]
13
+ NETWORK_ERRORS = [Timeout::Error,
14
+ Errno::EINVAL,
15
+ Errno::ECONNRESET,
16
+ EOFError,
17
+ Errno::ECONNREFUSED,
18
+ Net::HTTPBadResponse,
19
+ Net::HTTPHeaderSyntaxError,
20
+ Net::ProtocolError].freeze
21
21
 
22
22
  def do_post_request(path, body)
23
23
  response = Net::HTTP.post_form(URI(path), **body)
@@ -29,7 +29,7 @@ module Hydra
29
29
  else
30
30
  Failure(status: response.code, code: :bad_keycloak_response)
31
31
  end
32
- rescue *NetworkErrors
32
+ rescue *NETWORK_ERRORS
33
33
  Failure(status: 400, code: :keycloak_unavailable)
34
34
  rescue JSON::ParserError
35
35
  Failure(status: 400, code: :json_parser_error)
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ begin
4
+ require 'dalli'
5
+ rescue LoadError
6
+ raise LoadError, 'You must add `dalli` into your project`s Gemfile and launch bundle install'
7
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ begin
4
+ require 'redis'
5
+ rescue LoadError
6
+ raise LoadError, 'You must add `redis` into your project`s Gemfile and launch bundle install'
7
+ end
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'dalli'
4
3
  require 'dry/monads'
5
4
  require 'dry/auto_inject'
6
5
 
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'redis'
4
3
  require 'dry/monads'
5
4
  require 'dry/auto_inject'
6
5
 
@@ -19,7 +19,7 @@ module Hydra
19
19
  @data = ::JWT.decode(source, nil, false).first.transform_keys(&:to_sym)
20
20
  end
21
21
 
22
- %i(exp iat auth_time iss session_state scope jti).each do |field|
22
+ %i[exp iat auth_time iss session_state scope jti].each do |field|
23
23
  define_method(field) do
24
24
  @data.fetch(field)
25
25
  end
@@ -16,7 +16,7 @@ module Hydra
16
16
  "nonce=#{@config[:secret]}&" \
17
17
  'scope=openid&' \
18
18
  "code_challenge=#{code_challenge}&" \
19
- "code_challenge_method=S256"
19
+ 'code_challenge_method=S256'
20
20
  end
21
21
 
22
22
  def token_endpoint
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Hydra
4
4
  module Keycloak
5
- VERSION = '0.1.7'
5
+ VERSION = '0.1.10'
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.7
4
+ version: 0.1.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fedor Kosolapov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-03-04 00:00:00.000000000 Z
11
+ date: 2022-04-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jwt
@@ -25,7 +25,7 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: dalli
28
+ name: dry-auto_inject
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
@@ -39,7 +39,7 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: redis
42
+ name: dry-container
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
@@ -66,34 +66,6 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
- - !ruby/object:Gem::Dependency
70
- name: dry-auto_inject
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: '0'
76
- type: :runtime
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: '0'
83
- - !ruby/object:Gem::Dependency
84
- name: dry-container
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: '0'
90
- type: :runtime
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - ">="
95
- - !ruby/object:Gem::Version
96
- version: '0'
97
69
  - !ruby/object:Gem::Dependency
98
70
  name: dry-schema
99
71
  requirement: !ruby/object:Gem::Requirement
@@ -132,6 +104,7 @@ extensions: []
132
104
  extra_rdoc_files: []
133
105
  files:
134
106
  - ".github/workflows/main.yml"
107
+ - ".rubocop.yml"
135
108
  - Dockerfile.test
136
109
  - Gemfile
137
110
  - Gemfile.lock
@@ -145,6 +118,8 @@ files:
145
118
  - lib/hydra/keycloak/container.rb
146
119
  - lib/hydra/keycloak/queries/gateway.rb
147
120
  - lib/hydra/keycloak/queries/http_client.rb
121
+ - lib/hydra/keycloak/store/adapters/memcached.rb
122
+ - lib/hydra/keycloak/store/adapters/redis.rb
148
123
  - lib/hydra/keycloak/store/gateway.rb
149
124
  - lib/hydra/keycloak/store/memcached_client.rb
150
125
  - lib/hydra/keycloak/store/redis_client.rb
@@ -166,7 +141,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
166
141
  requirements:
167
142
  - - ">="
168
143
  - !ruby/object:Gem::Version
169
- version: 2.3.0
144
+ version: 2.5.8
170
145
  required_rubygems_version: !ruby/object:Gem::Requirement
171
146
  requirements:
172
147
  - - ">="