Sha256: 12517641c4213fd012bc1f281b8f699c923ec92b0d38c16fe8e3903325b02a6b

Contents?: true

Size: 721 Bytes

Versions: 4

Compression:

Stored size: 721 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 resource && validate(resource)
          success! resource
        else
          fail(:invalid_token)
        end
      end
    end
  end
end

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
anjlab-devise-oauth2-providable-1.1.3 lib/devise/oauth2_providable/strategies/oauth2_providable_strategy.rb
anjlab-devise-oauth2-providable-1.1.2 lib/devise/oauth2_providable/strategies/oauth2_providable_strategy.rb
anjlab-devise-oauth2-providable-1.1.1 lib/devise/oauth2_providable/strategies/oauth2_providable_strategy.rb
anjlab-devise-oauth2-providable-1.1.0 lib/devise/oauth2_providable/strategies/oauth2_providable_strategy.rb