Sha256: 184a637cad82dc075a52dd8f15edb704c76254dd14de81a06b2aac91b39f5e33

Contents?: true

Size: 655 Bytes

Versions: 3

Compression:

Stored size: 655 Bytes

Contents

# frozen_string_literal: true

module KeycloakRack
  # Fetches the public key for a keycloak installation.
  #
  # @api private
  class KeyFetcher
    include Import[config: "keycloak-rack.config", http_client: "keycloak-rack.http_client"]

    delegate :realm_id, to: :config

    # @return [Dry::Monads::Success({ Symbol => Object })]
    # @return [Dry::Monads::Failure(Symbol, String)]
    def find_public_keys
      http_client.get_json(realm_id, "protocol/openid-connect/certs").or do |(code, reason, response)|
        Dry::Monads::Result::Failure[:invalid_public_keys, "Could not fetch public keys: #{reason.inspect}"]
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
keycloak_rack-1.1.1 lib/keycloak_rack/key_fetcher.rb
keycloak_rack-1.1.0 lib/keycloak_rack/key_fetcher.rb
keycloak_rack-1.0.0 lib/keycloak_rack/key_fetcher.rb