Sha256: ed39ecf7411d3dcf104999f2bf2181c7627d32a8666dae7ae154aa317831751c

Contents?: true

Size: 488 Bytes

Versions: 2

Compression:

Stored size: 488 Bytes

Contents

# frozen_string_literal: true

require "uri"
require "json"
require "net/http"

module JwkLoader
  module Jwks
    class << self
      def from_uri(uri)
        uri = URI.parse(uri) unless uri.is_a?(URI)

        response = Net::HTTP.get_response(uri)
        from_json(response.body)
      end

      def from_memory(uri)
        JwkLoader.memory_store.fetch(uri)
      end

      def from_json(jwks_json)
        JSON.parse(jwks_json, symbolize_names: true)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
jwk-loader-1.1.0 lib/jwk_loader/jwks.rb
jwk-loader-1.0.0 lib/jwk_loader/jwks.rb