Sha256: cac92ce2eeb541fbfd30c88c6e8e453f42dda6488cc69a2b68bc8e89410b164d

Contents?: true

Size: 679 Bytes

Versions: 8

Compression:

Stored size: 679 Bytes

Contents

require 'devise/strategies/base'

module Devise
  module Strategies
    class Oauth2Providable < Authenticatable
      def valid?
        @req = Rack::OAuth2::Server::Resource::Bearer::Request.new(env)
        @req.oauth2?
      end
      def authenticate!
        @req.setup!
        token = AccessToken.valid.find_by_token @req.access_token
        env['oauth2.client'] = token ? token.client : nil
        resource = token ? token.user : nil
        if validate(resource)
          success! resource
        elsif !halted?
          fail(:invalid_token)
        end
      end
    end
  end
end

Warden::Strategies.add(:oauth2_providable, Devise::Strategies::Oauth2Providable)

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
devise_oauth2_providable-0.3.8 lib/devise_oauth2_providable/strategy.rb
devise_oauth2_providable-0.3.7 lib/devise_oauth2_providable/strategy.rb
devise_oauth2_providable-0.3.6 lib/devise_oauth2_providable/strategy.rb
devise_oauth2_providable-0.3.5 lib/devise_oauth2_providable/strategy.rb
devise_oauth2_providable-0.3.4 lib/devise_oauth2_providable/strategy.rb
devise_oauth2_providable-0.3.3 lib/devise_oauth2_providable/strategy.rb
devise_oauth2_providable-0.3.2 lib/devise_oauth2_providable/strategy.rb
devise_oauth2_providable-0.3.1 lib/devise_oauth2_providable/strategy.rb