Sha256: f47693de90ffdaa243fcf85289c707aeb7aa437c0399d0629ed4ffea641443be

Contents?: true

Size: 843 Bytes

Versions: 1

Compression:

Stored size: 843 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

1 entries across 1 versions & 1 rubygems

Version Path
couchkeeper-0.6.7 lib/doorkeeper/oauth/client_credentials/validation.rb