Sha256: 1dcec0b580e9e1e43bcaae81a96aea73276ce9544d1ca78e518750b1e1609628

Contents?: true

Size: 678 Bytes

Versions: 13

Compression:

Stored size: 678 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 = Devise::Oauth2::AccessToken.find_by_token @req.access_token
        env[Devise::Oauth2::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, Devise::Strategies::Oauth2Providable)

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
devise_oauth2_rails4-2.1.4 lib/devise/oauth2/strategies/oauth2_providable_strategy.rb
devise_oauth2_rails4-2.1.3 lib/devise/oauth2/strategies/oauth2_providable_strategy.rb
devise_oauth2_rails4-2.0.3 lib/devise/oauth2/strategies/oauth2_providable_strategy.rb
devise_oauth2_rails4-2.1.0 lib/devise/oauth2/strategies/oauth2_providable_strategy.rb
devise_oauth2_rails4-2.0.2 lib/devise/oauth2/strategies/oauth2_providable_strategy.rb
devise_oauth2_rails4-2.0.1 lib/devise/oauth2/strategies/oauth2_providable_strategy.rb
devise_oauth2_rails4-2.0.0 lib/devise/oauth2/strategies/oauth2_providable_strategy.rb
devise_oauth2_rails4-1.1.8 lib/devise/oauth2/strategies/oauth2_providable_strategy.rb
devise_oauth2_rails4-1.1.7 lib/devise/oauth2/strategies/oauth2_providable_strategy.rb
devise_oauth2_rails4-1.1.6 lib/devise/oauth2/strategies/oauth2_providable_strategy.rb
devise_oauth2_rails4-1.1.5 lib/devise/oauth2/strategies/oauth2_providable_strategy.rb
devise_oauth2_rails4-1.1.4 lib/devise/oauth2/strategies/oauth2_providable_strategy.rb
devise_oauth2_rails4-1.1.3 lib/devise/oauth2/strategies/oauth2_providable_strategy.rb