Class: Hydra::Keycloak::ClientCreator
- Inherits:
-
Object
- Object
- Hydra::Keycloak::ClientCreator
show all
- Extended by:
- Mixin
- Defined in:
- lib/hydra/keycloak/client.rb
Class Method Summary
collapse
Methods included from Mixin
args_inject, container, inject
Class Method Details
.call(config:) ⇒ Object
42
43
44
|
# File 'lib/hydra/keycloak/client.rb', line 42
def call(config:)
register_containers(validate_config(config).to_h)
end
|
.register_code_verifier ⇒ Object
121
122
123
|
# File 'lib/hydra/keycloak/client.rb', line 121
def register_code_verifier
container.register(:code_verifier, ::Hydra::Keycloak::CodeVerifier.new)
end
|
.register_containers(validated_config) ⇒ Object
56
57
58
59
60
61
62
63
|
# File 'lib/hydra/keycloak/client.rb', line 56
def register_containers(validated_config)
register_urls(validated_config)
register_store_client(validated_config)
register_store
register_code_verifier
::Hydra::Keycloak::Client.new
end
|
.register_memcached_store(memcached_host:, memcached_port:, memcached_namespace:) ⇒ Object
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
# File 'lib/hydra/keycloak/client.rb', line 96
def register_memcached_store(memcached_host:, memcached_port:, memcached_namespace:)
require 'hydra/keycloak/store/adapters/memcached'
container.register :dalli do
::Dalli::Client.new(
"#{memcached_host}:#{memcached_port}",
namespace: memcached_namespace
)
end
container.register :store_client do
require 'hydra/keycloak/store/memcached_client'
::Hydra::Keycloak::Store::MemcachedClient.new
end
end
|
.register_redis_store(redis_host:, redis_port:) ⇒ Object
82
83
84
85
86
87
88
89
90
91
92
93
94
|
# File 'lib/hydra/keycloak/client.rb', line 82
def register_redis_store(redis_host:, redis_port:)
require 'hydra/keycloak/store/adapters/redis'
container.register :redis do
::Redis.new(host: redis_host, port: redis_port)
end
container.register :store_client do
require 'hydra/keycloak/store/redis_client'
::Hydra::Keycloak::Store::RedisClient.new
end
end
|
.register_store ⇒ Object
113
114
115
116
117
118
119
|
# File 'lib/hydra/keycloak/client.rb', line 113
def register_store
container.register :store do
require 'hydra/keycloak/store/gateway'
::Hydra::Keycloak::Store::Gateway.new
end
end
|
.register_store_client(config) ⇒ Object
73
74
75
76
77
78
79
80
|
# File 'lib/hydra/keycloak/client.rb', line 73
def register_store_client(config)
case config.fetch(:store_client)
when 'redis'
register_redis_store(**config.fetch(:store_client_options))
when 'memcached'
register_memcached_store(**config.fetch(:store_client_options))
end
end
|
.register_urls(config) ⇒ Object
65
66
67
68
69
70
71
|
# File 'lib/hydra/keycloak/client.rb', line 65
def register_urls(config)
container.register :urls do
require 'hydra/keycloak/urls'
::Hydra::Keycloak::Urls.new(config)
end
end
|
.validate_config(config) ⇒ Object
46
47
48
49
50
51
52
53
54
|
# File 'lib/hydra/keycloak/client.rb', line 46
def validate_config(config)
validated_config = CONFIG_SCHEMA.call(config)
if validated_config.failure?
raise ConfigurationError, "Wrong configuration params: #{validated_config.errors(full: true).to_h}"
end
validated_config
end
|