Sha256: 77af8ee5237a23bd92415b4132506111ec9f0874da28779ea78e8b7b158f25d1

Contents?: true

Size: 1.21 KB

Versions: 10

Compression:

Stored size: 1.21 KB

Contents

require 'doorkeeper/request/authorization_code'
require 'doorkeeper/request/client_credentials'
require 'doorkeeper/request/code'
require 'doorkeeper/request/password'
require 'doorkeeper/request/refresh_token'
require 'doorkeeper/request/token'

module Doorkeeper
  module Request
    module_function

    def authorization_strategy(response_type)
      get_strategy response_type, authorization_response_types
    rescue NameError
      raise Errors::InvalidAuthorizationStrategy
    end

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

    def get_strategy(grant_or_request_type, available)
      fail Errors::MissingRequestStrategy unless grant_or_request_type.present?
      fail NameError unless available.include?(grant_or_request_type.to_s)
      "Doorkeeper::Request::#{grant_or_request_type.to_s.camelize}".constantize
    end

    def authorization_response_types
      Doorkeeper.configuration.authorization_response_types
    end
    private_class_method :authorization_response_types

    def token_grant_types
      Doorkeeper.configuration.token_grant_types
    end
    private_class_method :token_grant_types
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
doorkeeper-4.2.6 lib/doorkeeper/request.rb
doorkeeper-4.2.5 lib/doorkeeper/request.rb
doorkeeper-4.2.0 lib/doorkeeper/request.rb
doorkeeper-4.1.0 lib/doorkeeper/request.rb
doorkeeper-4.0.0 lib/doorkeeper/request.rb
doorkeeper-4.0.0.rc4 lib/doorkeeper/request.rb
doorkeeper-4.0.0.rc3 lib/doorkeeper/request.rb
doorkeeper-4.0.0.rc2 lib/doorkeeper/request.rb
doorkeeper-4.0.0.rc1 lib/doorkeeper/request.rb
doorkeeper-3.1.0 lib/doorkeeper/request.rb