Class: WardenOpenidAuth::JWKS
- Inherits:
-
Object
- Object
- WardenOpenidAuth::JWKS
- Defined in:
- lib/warden_openid_auth/jwks.rb
Overview
Represents a JSON Web Key Set. It will cache the results of the web request to get the JWKS so that it does not need to make an external request for the JWKS to authenticate every user.
Instance Attribute Summary collapse
-
#cache ⇒ Object
readonly
Returns the value of attribute cache.
-
#cache_options ⇒ Object
readonly
Returns the value of attribute cache_options.
-
#jwks_url ⇒ Object
readonly
Returns the value of attribute jwks_url.
Instance Method Summary collapse
-
#initialize(jwks_url:, config: WardenOpenidAuth.config) ⇒ JWKS
constructor
A new instance of JWKS.
-
#key_set ⇒ Hash
Checks the cache to see if it contains the JSON Web Key Set and returns it.
Constructor Details
#initialize(jwks_url:, config: WardenOpenidAuth.config) ⇒ JWKS
Returns a new instance of JWKS.
13 14 15 16 17 |
# File 'lib/warden_openid_auth/jwks.rb', line 13 def initialize(jwks_url:, config: WardenOpenidAuth.config) @jwks_url = jwks_url @cache = config.cache @cache_options = config. end |
Instance Attribute Details
#cache ⇒ Object (readonly)
Returns the value of attribute cache.
9 10 11 |
# File 'lib/warden_openid_auth/jwks.rb', line 9 def cache @cache end |
#cache_options ⇒ Object (readonly)
Returns the value of attribute cache_options.
9 10 11 |
# File 'lib/warden_openid_auth/jwks.rb', line 9 def @cache_options end |
#jwks_url ⇒ Object (readonly)
Returns the value of attribute jwks_url.
9 10 11 |
# File 'lib/warden_openid_auth/jwks.rb', line 9 def jwks_url @jwks_url end |
Instance Method Details
#key_set ⇒ Hash
Checks the cache to see if it contains the JSON Web Key Set and returns it. If it is not in the cache it will fetch it from the URL specified.
23 24 25 26 27 28 |
# File 'lib/warden_openid_auth/jwks.rb', line 23 def key_set result = cache.read(cache_key) return result unless result.nil? fetch_and_store_jwks end |