Class: Keycloak::PublicKeyCachedResolver

Inherits:
Object
  • Object
show all
Defined in:
lib/keycloak-api-rails/public_key_cached_resolver.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(http_client, realm_id, public_key_cache_ttl) ⇒ PublicKeyCachedResolver

Returns a new instance of PublicKeyCachedResolver.



5
6
7
8
9
10
# File 'lib/keycloak-api-rails/public_key_cached_resolver.rb', line 5

def initialize(http_client, realm_id, public_key_cache_ttl)
  @resolver                       = PublicKeyResolver.new(http_client, realm_id)
  @public_key_cache_ttl           = public_key_cache_ttl
  @cached_public_keys             = nil
  @cached_public_key_retrieved_at = nil
end

Instance Attribute Details

#cached_public_key_retrieved_atObject (readonly)

Returns the value of attribute cached_public_key_retrieved_at.



3
4
5
# File 'lib/keycloak-api-rails/public_key_cached_resolver.rb', line 3

def cached_public_key_retrieved_at
  @cached_public_key_retrieved_at
end

Class Method Details

.from_configuration(http_client, configuration) ⇒ Object



12
13
14
# File 'lib/keycloak-api-rails/public_key_cached_resolver.rb', line 12

def self.from_configuration(http_client, configuration)
  PublicKeyCachedResolver.new(http_client, configuration.realm_id, configuration.public_key_cache_ttl)
end

Instance Method Details

#find_public_keysObject



16
17
18
19
20
21
22
# File 'lib/keycloak-api-rails/public_key_cached_resolver.rb', line 16

def find_public_keys
  if public_keys_are_outdated?
    @cached_public_keys             = @resolver.find_public_keys
    @cached_public_key_retrieved_at = Time.now
  end
  @cached_public_keys
end