Module: JWT::JWK
- Defined in:
- lib/jwt/jwk.rb,
lib/jwt/jwk/ec.rb,
lib/jwt/jwk/rsa.rb,
lib/jwt/jwk/set.rb,
lib/jwt/jwk/hmac.rb,
lib/jwt/jwk/key_base.rb,
lib/jwt/jwk/key_finder.rb,
lib/jwt/jwk/okp_rbnacl.rb,
lib/jwt/jwk/thumbprint.rb,
lib/jwt/jwk/kid_as_key_digest.rb
Overview
JSON Web Key (JWK)
Defined Under Namespace
Classes: EC, HMAC, KeyBase, KeyFinder, KidAsKeyDigest, OKPRbNaCl, RSA, Set, Thumbprint
Class Method Summary collapse
- .classes ⇒ Object
- .create_from(key, params = nil, options = {}) ⇒ Object (also: new, import)
Class Method Details
.classes ⇒ Object
25 26 27 28 |
# File 'lib/jwt/jwk.rb', line 25 def classes @mappings = nil # reset the cached mappings @classes ||= [] end |
.create_from(key, params = nil, options = {}) ⇒ Object Also known as: new, import
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/jwt/jwk.rb', line 10 def create_from(key, params = nil, = {}) if key.is_a?(Hash) jwk_kty = key[:kty] || key['kty'] raise JWT::JWKError, 'Key type (kty) not provided' unless jwk_kty return mappings.fetch(jwk_kty.to_s) do |kty| raise JWT::JWKError, "Key type #{kty} not supported" end.new(key, params, ) end mappings.fetch(key.class) do |klass| raise JWT::JWKError, "Cannot create JWK from a #{klass.name}" end.new(key, params, ) end |