Sha256: 240ed3c44b1ea728a7b2649f50f3a6e1d1b7488a51545da0b96799e0bf742ddf

Contents?: true

Size: 719 Bytes

Versions: 6

Compression:

Stored size: 719 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::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
        elsif !halted?
          fail(:invalid_token)
        end
      end
    end
  end
end

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

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
devise_oauth2_providable-1.1.1 lib/devise/oauth2_providable/strategies/oauth2_providable_strategy.rb
devise_oauth2_providable-1.1.0 lib/devise/oauth2_providable/strategies/oauth2_providable_strategy.rb
devise_oauth2_providable-1.0.5 lib/devise/oauth2_providable/strategies/oauth2_providable_strategy.rb
devise_oauth2_providable-1.0.4 lib/devise/oauth2_providable/strategies/oauth2_providable_strategy.rb
devise_oauth2_providable-1.0.3 lib/devise/oauth2_providable/strategies/oauth2_providable_strategy.rb
devise_oauth2_providable-1.0.2 lib/devise/oauth2_providable/strategies/oauth2_providable_strategy.rb