Sha256: 7f3df0eae09b3f68a03b657fc6e0667993bd97f89c5595dafa57ff9d7c9293dd

Contents?: true

Size: 753 Bytes

Versions: 10

Compression:

Stored size: 753 Bytes

Contents

require 'devise/strategies/base'

module Devise
  module Strategies
    class Oauth2Providable < Authenticatable

      def store?
        false
      end

      def valid?
        @req = Rack::OAuth2::Server::Resource::Bearer::Request.new(env)
        @req.oauth2?
      end

      def authenticate!
        @req.setup!
        token = Devise::Oauth2Providable::AccessToken.find_by_token @req.access_token
        env[Devise::Oauth2Providable::CLIENT_ENV_REF] = token.client if token
        resource = token ? token.user : nil
        if validate(resource)
          success! resource
        else
          fail(:invalid_token)
        end
      end
    end
  end
end

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

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
brycesch-devise_oauth2_providable-1.2.8 lib/devise/oauth2_providable/strategies/oauth2_providable_strategy.rb
brycesch-devise_oauth2_providable-1.2.7 lib/devise/oauth2_providable/strategies/oauth2_providable_strategy.rb
brycesch-devise_oauth2_providable-1.2.6 lib/devise/oauth2_providable/strategies/oauth2_providable_strategy.rb
brycesch-devise_oauth2_providable-1.2.5 lib/devise/oauth2_providable/strategies/oauth2_providable_strategy.rb
brycesch-devise_oauth2_providable-1.2.4 lib/devise/oauth2_providable/strategies/oauth2_providable_strategy.rb
brycesch-devise_oauth2_providable-1.2.3 lib/devise/oauth2_providable/strategies/oauth2_providable_strategy.rb
brycesch-devise_oauth2_providable-1.2.2 lib/devise/oauth2_providable/strategies/oauth2_providable_strategy.rb
brycesch-devise_oauth2_providable-1.2.1 lib/devise/oauth2_providable/strategies/oauth2_providable_strategy.rb
brycesch-devise_oauth2_providable-1.2.0 lib/devise/oauth2_providable/strategies/oauth2_providable_strategy.rb
brycesch-devise_oauth2_providable-1.1.7 lib/devise/oauth2_providable/strategies/oauth2_providable_strategy.rb