Class: KeycloakRack::KeyResolver Private
- Inherits:
-
Object
- Object
- KeycloakRack::KeyResolver
- Defined in:
- lib/keycloak_rack/key_resolver.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
A caching resolver that wraps around KeyFetcher to cache its result for Config#cache_ttl seconds (default: 1.day)
Instance Attribute Summary collapse
- #cached_public_key_retrieved_at ⇒ ActiveSupport::TimeWithZone readonly private
- #cached_public_keys ⇒ Dry::Monads::Success({ Symbol => <{ Symbol => String }> }), Dry::Monads::Failure readonly private
Instance Method Summary collapse
- #find_public_keys ⇒ Dry::Monads::Success({ Symbol => Object }), Dry::Monads::Failure(Symbol, String) private
- #has_failed_fetch? ⇒ Boolean private
- #has_outdated_cache? ⇒ Boolean private
-
#initialize ⇒ KeyResolver
constructor
private
A new instance of KeyResolver.
- #refresh! ⇒ void private
- #should_refetch? ⇒ Boolean private
Constructor Details
#initialize ⇒ KeyResolver
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of KeyResolver.
22 23 24 25 26 27 |
# File 'lib/keycloak_rack/key_resolver.rb', line 22 def initialize(**) super @cached_public_keys = Dry::Monads.Failure("nothing fetched yet") @cached_public_key_retrieved_at = 1.year.ago end |
Instance Attribute Details
#cached_public_key_retrieved_at ⇒ ActiveSupport::TimeWithZone (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
15 16 17 |
# File 'lib/keycloak_rack/key_resolver.rb', line 15 def cached_public_key_retrieved_at @cached_public_key_retrieved_at end |
#cached_public_keys ⇒ Dry::Monads::Success({ Symbol => <{ Symbol => String }> }), Dry::Monads::Failure (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
20 21 22 |
# File 'lib/keycloak_rack/key_resolver.rb', line 20 def cached_public_keys @cached_public_keys end |
Instance Method Details
#find_public_keys ⇒ Dry::Monads::Success({ Symbol => Object }), Dry::Monads::Failure(Symbol, String)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
32 33 34 35 36 |
# File 'lib/keycloak_rack/key_resolver.rb', line 32 def find_public_keys fetch! if should_refetch? @cached_public_keys end |
#has_failed_fetch? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
38 39 40 |
# File 'lib/keycloak_rack/key_resolver.rb', line 38 def has_failed_fetch? @cached_public_keys.failure? end |
#has_outdated_cache? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
42 43 44 |
# File 'lib/keycloak_rack/key_resolver.rb', line 42 def has_outdated_cache? Time.current > @cached_public_key_expires_at end |
#refresh! ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
47 48 49 |
# File 'lib/keycloak_rack/key_resolver.rb', line 47 def refresh! fetch! end |
#should_refetch? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
51 52 53 |
# File 'lib/keycloak_rack/key_resolver.rb', line 51 def should_refetch? has_failed_fetch? || has_outdated_cache? end |