Sha256: 5deb618ede2cdafc6f764a43f552e79a41967b029b99408521d20fe08ea01827
Contents?: true
Size: 1.06 KB
Versions: 1
Compression:
Stored size: 1.06 KB
Contents
require 'devise/strategies/base' module Devise module Strategies class Oauth2Providable < Base def valid? @req = Rack::OAuth2::Server::Resource::Bearer::Request.new(env) @req.oauth2? end def authenticate! token = [@req.access_token_in_header, @req.access_token_in_payload].compact access_token = AccessToken.valid.find_by_token token resource = access_token ? access_token.user : nil if validate(resource) success! resource elsif !halted? fail(:invalid_token) end end private # Simply invokes valid_for_authentication? with the given block and deal with the result. def validate(resource, &block) result = resource && resource.valid_for_authentication?(&block) case result when String, Symbol fail!(result) false when TrueClass true else result end end end end end Warden::Strategies.add(:oauth2_providable, Devise::Strategies::Oauth2Providable)
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
devise_oauth2_providable-0.2.1 | lib/devise_oauth2_providable/strategy.rb |