Sha256: b54ff98053b69f6ef3c94dd9652a594160b54cd8bea7b31b15a70a1eeecb0a19

Contents?: true

Size: 1.05 KB

Versions: 16

Compression:

Stored size: 1.05 KB

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, @client = server, request, request.client

          validate
        end

        private

        def validate_client
          @client.present?
        end

        def validate_scopes
          return true unless @request.scopes.present?

          application_scopes = if @client.present?
                                 @client.application.scopes
                               else
                                 ''
                               end

          ScopeChecker.valid?(
            @request.scopes.to_s,
            @server.scopes,
            application_scopes
          )
        end
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
doorkeeper-4.2.0 lib/doorkeeper/oauth/client_credentials/validation.rb
doorkeeper-4.1.0 lib/doorkeeper/oauth/client_credentials/validation.rb
doorkeeper-4.0.0 lib/doorkeeper/oauth/client_credentials/validation.rb
doorkeeper-4.0.0.rc4 lib/doorkeeper/oauth/client_credentials/validation.rb
doorkeeper-4.0.0.rc3 lib/doorkeeper/oauth/client_credentials/validation.rb
doorkeeper-4.0.0.rc2 lib/doorkeeper/oauth/client_credentials/validation.rb
doorkeeper-4.0.0.rc1 lib/doorkeeper/oauth/client_credentials/validation.rb
doorkeeper-3.1.0 lib/doorkeeper/oauth/client_credentials/validation.rb
doorkeeper-3.0.1 lib/doorkeeper/oauth/client_credentials/validation.rb
doorkeeper-2.2.2 lib/doorkeeper/oauth/client_credentials/validation.rb
doorkeeper-3.0.0 lib/doorkeeper/oauth/client_credentials/validation.rb
doorkeeper-3.0.0.rc2 lib/doorkeeper/oauth/client_credentials/validation.rb
doorkeeper-3.0.0.rc1 lib/doorkeeper/oauth/client_credentials/validation.rb
doorkeeper-2.2.1 lib/doorkeeper/oauth/client_credentials/validation.rb
doorkeeper-2.2.0 lib/doorkeeper/oauth/client_credentials/validation.rb
doorkeeper-2.1.4 lib/doorkeeper/oauth/client_credentials/validation.rb