Sha256: fedccee2be85676ee35f8073421dcaf81ef8e7c2f83572fcc505635978155b45

Contents?: true

Size: 867 Bytes

Versions: 2

Compression:

Stored size: 867 Bytes

Contents

# frozen_string_literal: true

require_relative "jwk_loader/version"
require_relative "jwk_loader/jwks"
require_relative "jwk_loader/jwks_uri_provider"
require_relative "jwk_loader/memory_cache"
require_relative "jwk_loader/error"
require_relative "jwk_loader/config/config"

module JwkLoader
  class << self
    def for_uri(**options)
      options[:cache] ||= config[:cache]
      options[:cache_grace_period] ||= config[:cache_grace_period]
      JwksUriProvider.new(**options)
    end

    def cache
      config[:cache]
    end

    def configure
      yield config
    end

    def config
      @config ||= JwkLoader::Config.new.tap do |cfg|
        cfg[:cache] = MemoryCache.new
        cfg[:cache_grace_period] = 900
      end
    end

    def reset!
      @config = nil
    end

    def memory_store
      @memory_store ||= MemoryCache.new
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

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