Sha256: 0ec9d4174f2816c231242b43a1a683265f78bf40924bcaf9c1b6100d90d46371

Contents?: true

Size: 926 Bytes

Versions: 7

Compression:

Stored size: 926 Bytes

Contents

# frozen_string_literal: true

module Doorkeeper
  module Request
    class << self
      def authorization_strategy(response_type)
        build_strategy_class(response_type)
      end

      def token_strategy(grant_type)
        raise Errors::MissingRequiredParameter, :grant_type if grant_type.blank?

        get_strategy(grant_type, token_grant_types)
      rescue NameError
        raise Errors::InvalidTokenStrategy
      end

      def get_strategy(grant_type, available)
        raise NameError unless available.include?(grant_type.to_s)

        build_strategy_class(grant_type)
      end

      private

      def token_grant_types
        Doorkeeper.config.token_grant_types
      end

      def build_strategy_class(grant_or_request_type)
        strategy_class_name = grant_or_request_type.to_s.tr(" ", "_").camelize
        "Doorkeeper::Request::#{strategy_class_name}".constantize
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
doorkeeper-5.4.0 lib/doorkeeper/request.rb
doorkeeper-5.3.3 lib/doorkeeper/request.rb
doorkeeper-5.4.0.rc2 lib/doorkeeper/request.rb
doorkeeper-5.3.2 lib/doorkeeper/request.rb
doorkeeper-5.4.0.rc1 lib/doorkeeper/request.rb
doorkeeper-5.3.1 lib/doorkeeper/request.rb
doorkeeper-5.3.0 lib/doorkeeper/request.rb