Sha256: 38cb91888d0e92bde0734eef50311272fbb5872236769ef209ed11977df5808f

Contents?: true

Size: 1.25 KB

Versions: 21

Compression:

Stored size: 1.25 KB

Contents

module Doorkeeper
  class Server
    attr_accessor :context

    def initialize(context = nil)
      @context = context
    end

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

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

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

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

    def client_via_uid
      @client_via_uid ||= OAuth::Client.find(parameters[:client_id])
    end

    def current_resource_owner
      context.send :current_resource_owner
    end

    def current_refresh_token
      Doorkeeper::AccessToken.by_refresh_token(parameters[:refresh_token])
    end

    def grant
      Doorkeeper::AccessGrant.authenticate(parameters[:code])
    end

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

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

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
doorkeeper-1.3.1 lib/doorkeeper/server.rb
doorkeeper-1.3.0 lib/doorkeeper/server.rb
doorkeeper-1.2.0 lib/doorkeeper/server.rb
doorkeeper-1.1.0 lib/doorkeeper/server.rb
doorkeeper-1.0.0 lib/doorkeeper/server.rb
doorkeeper-1.0.0.rc2 lib/doorkeeper/server.rb
doorkeeper-1.0.0.rc1 lib/doorkeeper/server.rb
doorkeeper-0.7.4 lib/doorkeeper/server.rb
doorkeeper-0.7.3 lib/doorkeeper/server.rb
doorkeeper-0.7.2 lib/doorkeeper/server.rb
doorkeeper-0.7.1 lib/doorkeeper/server.rb
doorkeeper-0.7.0 lib/doorkeeper/server.rb
doorkeeper-0.6.7 lib/doorkeeper/server.rb
doorkeeper-0.6.6 lib/doorkeeper/server.rb
doorkeeper-0.6.5 lib/doorkeeper/server.rb
doorkeeper-0.6.4 lib/doorkeeper/server.rb
doorkeeper-0.6.3 lib/doorkeeper/server.rb
doorkeeper-0.6.2 lib/doorkeeper/server.rb
doorkeeper-0.6.1 lib/doorkeeper/server.rb
doorkeeper-0.6.0 lib/doorkeeper/server.rb