Sha256: 02dd439c8c3967a6f6dc20a64f7555be219f260979877bd6011f026a39523800

Contents?: true

Size: 865 Bytes

Versions: 1

Compression:

Stored size: 865 Bytes

Contents

require 'singleton'

module PansophyAuthenticator
  class ApplicationKeys
    include Singleton

    %i(own key valid? validate!).each do |method|
      define_singleton_method(method) { |*args| instance.send(method, *args) }
    end

    def own
      key(configuration.application)
    end

    def key(application)
      matcher(application).key
    end

    def valid?(application, key)
      matcher(application).valid?(key)
    end

    def validate!(application, key)
      matcher(application).validate!(key)
    end

    private

    def matcher(application)
      Matcher.new(retriever.instance.keys, application)
    end

    def retriever
      if PansophyAuthenticator.remote?
        Remote::ApplicationKeys
      else
        Local::ApplicationKeys
      end
    end

    def configuration
      PansophyAuthenticator.configuration
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pansophy_authenticator-0.1.0 lib/pansophy_authenticator/application_keys.rb