Sha256: b18323d2cb770afa7a008abcec2170e75196cce2b934ce1e28b42d0215d3e1f7

Contents?: true

Size: 804 Bytes

Versions: 3

Compression:

Stored size: 804 Bytes

Contents

require 'doorkeeper/validations'
require 'doorkeeper/oauth/scopes'
require 'doorkeeper/oauth/helpers/scope_checker'

module Doorkeeper
  module OAuth
    class ClientCredentialsRequest
      class Validation
        include Doorkeeper::Validations
        include Doorkeeper::OAuth::Helpers

        validate :client, error: :invalid_client
        validate :scopes, error: :invalid_scope

        def initialize(server, request)
          @server, @request = server, request
          validate
        end

        private

        def validate_client
          @request.client.present?
        end

        def validate_scopes
          return true unless @request.original_scopes.present?
          ScopeChecker.valid?(@request.original_scopes, @server.scopes)
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
doorkeeper-1.3.1 lib/doorkeeper/oauth/client_credentials/validation.rb
doorkeeper-1.3.0 lib/doorkeeper/oauth/client_credentials/validation.rb
doorkeeper-1.2.0 lib/doorkeeper/oauth/client_credentials/validation.rb