Sha256: d69f5bf1167ffffa4ffb53cc668687760c16a6ac71f612c2e6359bbee7514e58

Contents?: true

Size: 1.24 KB

Versions: 19

Compression:

Stored size: 1.24 KB

Contents

module Doorkeeper
  module OAuth
    class AuthorizationCodeRequest
      include Validations
      include OAuth::RequestConcern

      validate :attributes,   error: :invalid_request
      validate :client,       error: :invalid_client
      validate :grant,        error: :invalid_grant
      validate :redirect_uri, error: :invalid_grant

      attr_accessor :server, :grant, :client, :redirect_uri, :access_token

      def initialize(server, grant, client, parameters = {})
        @server = server
        @client = client
        @grant  = grant
        @redirect_uri = parameters[:redirect_uri]
      end

      private

      def before_successful_response
        grant.revoke
        find_or_create_access_token(grant.application,
                                    grant.resource_owner_id,
                                    grant.scopes,
                                    server)
      end

      def validate_attributes
        redirect_uri.present?
      end

      def validate_client
        !!client
      end

      def validate_grant
        return false unless grant && grant.application_id == client.id
        grant.accessible?
      end

      def validate_redirect_uri
        grant.redirect_uri == redirect_uri
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
doorkeeper-2.2.2 lib/doorkeeper/oauth/authorization_code_request.rb
doorkeeper-3.0.0 lib/doorkeeper/oauth/authorization_code_request.rb
doorkeeper-3.0.0.rc2 lib/doorkeeper/oauth/authorization_code_request.rb
doorkeeper-3.0.0.rc1 lib/doorkeeper/oauth/authorization_code_request.rb
doorkeeper-2.2.1 lib/doorkeeper/oauth/authorization_code_request.rb
doorkeeper-2.2.0 lib/doorkeeper/oauth/authorization_code_request.rb
doorkeeper-2.1.4 lib/doorkeeper/oauth/authorization_code_request.rb
doorkeeper-1.4.2 lib/doorkeeper/oauth/authorization_code_request.rb
doorkeeper-2.1.3 lib/doorkeeper/oauth/authorization_code_request.rb
doorkeeper-2.1.2 lib/doorkeeper/oauth/authorization_code_request.rb
doorkeeper-2.1.1 lib/doorkeeper/oauth/authorization_code_request.rb
doorkeeper-2.1.0 lib/doorkeeper/oauth/authorization_code_request.rb
doorkeeper-2.0.1 lib/doorkeeper/oauth/authorization_code_request.rb
doorkeeper-1.4.1 lib/doorkeeper/oauth/authorization_code_request.rb
doorkeeper-2.0.0 lib/doorkeeper/oauth/authorization_code_request.rb
doorkeeper-2.0.0.rc3 lib/doorkeeper/oauth/authorization_code_request.rb
doorkeeper-2.0.0.rc2 lib/doorkeeper/oauth/authorization_code_request.rb
doorkeeper-2.0.0.alpha1 lib/doorkeeper/oauth/authorization_code_request.rb
doorkeeper-1.4.0 lib/doorkeeper/oauth/authorization_code_request.rb