JWK Set - nov/json-jwt GitHub Wiki
JSON Web Key Set (JWKs)
Encoding
JSON::JWK::Set can be initiated by putting an array of JSON::JWK instances, or Hash represented JSON Web Key Set.
JSON::JWK::Set.new(jwk1, jwk2, jwk3, ...)
JSON::JWK::Set.new([jwk1, jwk2, jwk3, ...])
JSON::JWK::Set.new(
  keys: [{
    kty: :RSA,
    e: 'AQAB',
    n: 'AK8ppaAGn6N3jDic2...'
  }, {
    :
  }]
)
To encode to JSON, call JSON::JWK::Set#to_json.
Decoding
jwks_json = JSON.parse jwks_string
JSON::JWK::Set.new jwks_json
Detecting
jwks[kid]
Fetching
# NOTE: Optionally by setting cache instance, JWKs are cached by kid.
JSON::JWK::Set::Fetcher.cache = Rails.cache
JSON::JWK::Set::Fetcher.fetch(jwks_uri, kid: kid)
# => returns JSON::JWK instance or raise JSON::JWK::Set::KidNotFound
JSON::JWK::Set::Fetcher.fetch(jwks_uri, kid: kid, auto_detect: false)
# => returns JSON::JWK::Set without JWK detection by given kid (NOTE: kid is still required for caching)