-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathkeycloak_service.rb
42 lines (31 loc) · 1.02 KB
/
keycloak_service.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# frozen_string_literal: true
class Integration::KeycloakService < Integration::AbstractService
self.adapter_class = ::KeycloakAdapter
def remove(client)
payload = { client: client, adapter: adapter }
ActiveSupport::Notifications.instrument('remove_client.oidc', payload) do
adapter.delete_client(client)
end
end
def persist(client)
update_client = Concurrent::SafeTaskExecutor.new(method(:update_client))
updated, value, _error = update_client.execute(client)
updated ? value : adapter.create_client(client)
end
def create_client(client)
payload = { client: client, adapter: adapter }
ActiveSupport::Notifications.instrument('create_client.oidc', payload) do
adapter.create_client(client)
end
end
def update_client(client)
payload = { client: client, adapter: adapter }
ActiveSupport::Notifications.instrument('update_client.oidc', payload) do
adapter.update_client(client)
end
end
protected
def persist?(client)
client.secret
end
end