Sha256: 66ffd76a5c91497ecc91d4ae7181937878f7ee29b95669aec75bccbeb5525333

Contents?: true

Size: 996 Bytes

Versions: 23

Compression:

Stored size: 996 Bytes

Contents

# frozen_string_literal: true

module Doorkeeper
  class Server
    attr_reader :context

    def initialize(context)
      @context = context
    end

    def authorization_request(strategy)
      klass = Request.authorization_strategy(strategy)
      klass.new(self)
    end

    def token_request(strategy)
      klass = Request.token_strategy(strategy)
      klass.new(self)
    end

    # TODO: context should be the request
    def parameters
      context.request.parameters
    end

    def client
      @client ||= OAuth::Client.authenticate(credentials)
    end

    def current_resource_owner
      context.send :current_resource_owner
    end

    # TODO: Use configuration and evaluate proper context on block
    def resource_owner
      context.send :resource_owner_from_credentials
    end

    def credentials
      methods = Doorkeeper.config.client_credentials_methods
      @credentials ||= OAuth::Client::Credentials.from_request(context.request, *methods)
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
doorkeeper-5.8.0 lib/doorkeeper/server.rb
doorkeeper-5.7.1 lib/doorkeeper/server.rb
doorkeeper-5.7.0 lib/doorkeeper/server.rb
doorkeeper-5.6.9 lib/doorkeeper/server.rb
doorkeeper-5.6.8 lib/doorkeeper/server.rb
doorkeeper-5.6.7 lib/doorkeeper/server.rb
doorkeeper-5.6.6 lib/doorkeeper/server.rb
doorkeeper-5.6.5 lib/doorkeeper/server.rb
doorkeeper-5.6.4 lib/doorkeeper/server.rb
doorkeeper-5.6.3 lib/doorkeeper/server.rb
doorkeeper-5.6.2 lib/doorkeeper/server.rb
doorkeeper-5.6.1 lib/doorkeeper/server.rb
doorkeeper-5.6.0 lib/doorkeeper/server.rb
doorkeeper-5.6.0.rc2 lib/doorkeeper/server.rb
doorkeeper-5.6.0.rc1 lib/doorkeeper/server.rb
doorkeeper-5.5.4 lib/doorkeeper/server.rb
doorkeeper-5.5.3 lib/doorkeeper/server.rb
doorkeeper-5.5.2 lib/doorkeeper/server.rb
doorkeeper-5.5.1 lib/doorkeeper/server.rb
doorkeeper-5.5.0 lib/doorkeeper/server.rb