Sha256: 1c68f560eefeaf764b24b7a76e3bc454d072688e10ada468014f0574b1110d8d

Contents?: true

Size: 1006 Bytes

Versions: 1

Compression:

Stored size: 1006 Bytes

Contents

module Doorkeeper
  module OAuth
    class Token
      module Methods
        def from_access_token_param(request)
          request.parameters[:access_token]
        end

        def from_bearer_param(request)
          request.parameters[:bearer_token]
        end

        def from_bearer_authorization(request)
          pattern = /^Bearer /
          header  = request.authorization
          header.gsub pattern, '' if header && header.match(pattern)
        end
      end

      extend Methods

      def self.from_request(request, *methods)
        methods.inject(nil) do |credentials, method|
          method = self.method(method) if method.is_a?(Symbol)
          credentials = method.call(request)
          break credentials unless credentials.blank?
        end
      end

      def self.authenticate(request, *methods)
        token = from_request request, *methods
        Doorkeeper::AccessToken.authenticate(token) if token
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
couchkeeper-0.6.7 lib/doorkeeper/oauth/token.rb