Sha256: b5436f93972bfcb3f0bfc0db3cc9fff0eff338582166e483758806fd73da96da

Contents?: true

Size: 1002 Bytes

Versions: 4

Compression:

Stored size: 1002 Bytes

Contents

# frozen_string_literal: true

module Doorkeeper
  class Server
    attr_accessor :context

    def initialize(context = nil)
      @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

4 entries across 4 versions & 1 rubygems

Version Path
doorkeeper-5.3.3 lib/doorkeeper/server.rb
doorkeeper-5.3.2 lib/doorkeeper/server.rb
doorkeeper-5.3.1 lib/doorkeeper/server.rb
doorkeeper-5.3.0 lib/doorkeeper/server.rb