Class: JWT::JWK::KeyFinder
- Inherits:
-
Object
- Object
- JWT::JWK::KeyFinder
- Defined in:
- lib/jwt/jwk/key_finder.rb
Instance Method Summary collapse
-
#initialize(options) ⇒ KeyFinder
constructor
A new instance of KeyFinder.
- #key_for(kid) ⇒ Object
Constructor Details
#initialize(options) ⇒ KeyFinder
Returns a new instance of KeyFinder.
6 7 8 9 10 |
# File 'lib/jwt/jwk/key_finder.rb', line 6 def initialize() jwks_or_loader = [:jwks] @jwks = jwks_or_loader if jwks_or_loader.is_a?(Hash) @jwk_loader = jwks_or_loader if jwks_or_loader.respond_to?(:call) end |
Instance Method Details
#key_for(kid) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/jwt/jwk/key_finder.rb', line 12 def key_for(kid) raise ::JWT::DecodeError, 'No key id (kid) found from token headers' unless kid jwk = resolve_key(kid) raise ::JWT::DecodeError, "Could not find public key for kid #{kid}" unless jwk ::JWT::JWK.import(jwk).keypair end |