Class: JWT::JWK::KeyFinder Private
- Inherits:
-
Object
- Object
- JWT::JWK::KeyFinder
- Defined in:
- lib/jwt/jwk/key_finder.rb
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.
Instance Method Summary collapse
-
#initialize(options) ⇒ KeyFinder
constructor
private
A new instance of KeyFinder.
- #key_for(kid) ⇒ Object private
Constructor Details
#initialize(options) ⇒ KeyFinder
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 KeyFinder.
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/jwt/jwk/key_finder.rb', line 7 def initialize() @allow_nil_kid = [:allow_nil_kid] jwks_or_loader = [:jwks] @jwks_loader = if jwks_or_loader.respond_to?(:call) jwks_or_loader else ->() { jwks_or_loader } end end |
Instance Method Details
#key_for(kid) ⇒ Object
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.
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/jwt/jwk/key_finder.rb', line 18 def key_for(kid) raise ::JWT::DecodeError, 'No key id (kid) found from token headers' unless kid || @allow_nil_kid raise ::JWT::DecodeError, 'Invalid type for kid header parameter' unless kid.nil? || kid.is_a?(String) jwk = resolve_key(kid) raise ::JWT::DecodeError, 'No keys found in jwks' unless @jwks.any? raise ::JWT::DecodeError, "Could not find public key for kid #{kid}" unless jwk jwk.verify_key end |