Class: KeycloakSdk::KeycloakClient
- Inherits:
-
Object
- Object
- KeycloakSdk::KeycloakClient
- Defined in:
- lib/keycloak_sdk/client.rb
Overview
통합 진입점. auth는 즉시 조립, admin은 지연 조립(전용 캐싱 TokenProvider 주입 — §4).
Instance Attribute Summary collapse
-
#auth ⇒ Object
readonly
Returns the value of attribute auth.
Instance Method Summary collapse
- #admin ⇒ Object
- #close ⇒ Object
-
#initialize(config) ⇒ KeycloakClient
constructor
A new instance of KeycloakClient.
Constructor Details
#initialize(config) ⇒ KeycloakClient
Returns a new instance of KeycloakClient.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/keycloak_sdk/client.rb', line 8 def initialize(config) @config = config endpoints = OidcEndpoints.from_config(config) @form_http = Http.build(config) do |f| f.request :url_encoded f.response :json, content_type: /\bjson$/ end @jwks_http = Http.build(config) { |f| f.response :json, content_type: /\bjson$/ } jwks_store = JwksStore.new(jwks_url: endpoints.jwks, http: @jwks_http, min_refetch: config.jwks_min_refetch) jwt_validator = JwtValidator.from_config(config: config, jwks_store: jwks_store) @auth = AuthClient.new(config: config, http: @form_http, jwt_validator: jwt_validator) @admin = nil @admin_mutex = Mutex.new end |
Instance Attribute Details
#auth ⇒ Object (readonly)
Returns the value of attribute auth.
6 7 8 |
# File 'lib/keycloak_sdk/client.rb', line 6 def auth @auth end |
Instance Method Details
#admin ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/keycloak_sdk/client.rb', line 23 def admin @admin_mutex.synchronize do @admin ||= Admin::AdminClient.new( config: @config, token_provider: ClientCredentialsTokenProvider.new(config: @config, http: @form_http) ) end end |
#close ⇒ Object
32 33 34 35 36 |
# File 'lib/keycloak_sdk/client.rb', line 32 def close @admin&.close # 지연 생성된 admin의 Faraday 커넥션도 정리(§4 close 계약 — 이전엔 누락) [@form_http, @jwks_http].each { |h| h.close if h.respond_to?(:close) } nil end |