Sha256: fe3f79751b3889cb613f9e55a996f48608ee0fc5805bc5a02146d77df17a913e

Contents?: true

Size: 780 Bytes

Versions: 8

Compression:

Stored size: 780 Bytes

Contents

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

module Doorkeeper
  module OAuth
    class ClientCredentialsRequest
      class Validation
        include Validations
        include 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

8 entries across 8 versions & 1 rubygems

Version Path
doorkeeper-1.4.2 lib/doorkeeper/oauth/client_credentials/validation.rb
doorkeeper-2.0.1 lib/doorkeeper/oauth/client_credentials/validation.rb
doorkeeper-1.4.1 lib/doorkeeper/oauth/client_credentials/validation.rb
doorkeeper-2.0.0 lib/doorkeeper/oauth/client_credentials/validation.rb
doorkeeper-2.0.0.rc3 lib/doorkeeper/oauth/client_credentials/validation.rb
doorkeeper-2.0.0.rc2 lib/doorkeeper/oauth/client_credentials/validation.rb
doorkeeper-2.0.0.alpha1 lib/doorkeeper/oauth/client_credentials/validation.rb
doorkeeper-1.4.0 lib/doorkeeper/oauth/client_credentials/validation.rb